小编til*_*sup的帖子

GCM服务器端PHP - 未经授权的401错误

我设置了谷歌开发者控制台,支持Android版Google云消息传递.

在凭证方面,我创建了在引用中键入0.0.0.0的浏览器API密钥.实际上我创建了两种类型的键,因为我在不同的教程中找到了不同的指示.

浏览器关键图片

服务器密钥图片

我用这个PHP脚本测试了密钥

<?
/**
 * The following function will send a GCM notification using curl.
 * 
 * @param $apiKey       [string] The Browser API key string for your GCM account
 * @param $registrationIdsArray [array]  An array of registration ids to send this notification to
 * @param $messageData      [array]  An named array of data to send as the notification payload
 */
function sendNotification( $apiKey, $registrationIdsArray, $messageData )
{   
    $headers = array("Content-Type:" . "application/json", "Authorization:" . "key=" . …
Run Code Online (Sandbox Code Playgroud)

android google-api push-notification google-cloud-messaging

4
推荐指数
1
解决办法
5925
查看次数