连接以gcm重置

时间:2014-11-26 13:55:54

标签: android google-cloud-messaging

我正在使用此代码向设备发送推送通知

$registatoin_ids=array("DEVICE REG ID");
$message = array("product" => "shirt");
define("GOOGLE_API_KEY", "API KEY");
$url = 'https://android.googleapis.com/gcm/send';
$fields = array(
    'registration_ids' => $registatoin_ids,
    'data' => $message,
);
$headers = array(
    'Authorization:key=' . GOOGLE_API_KEY,
    'Content-Type:application/json'
);
$ch=curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
$result = curl_exec($ch);
if ($result === FALSE) {
    die('Curl failed: ' . curl_error($ch));
}
curl_close($ch);
echo $result;

但是当我尝试发送时,我在浏览器中显示“连接已重置”错误。可能导致此问题?

截图: enter image description here

Ps:Curl正在我的服务器上运行。

0 个答案:

没有答案