$registrationIds=array("My Key");
$fields = array
(
'registration_ids' => $registrationIds,
'data' => array
(
'message'=>'here is a message. message',
)
);
$key="1234444";
$headers = array
(
'Authorization:key='.$key,
'Content-Type: application/json'
);
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL, 'https://android.googleapis.com/gcm/send');
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);
curl_close($ch);
return $result;
輸出溶液:機器人推送通知與這些消息失敗任何一個有此
{multicast_id:7750113442176841000,成功:0,故障:1,canonical_ids:0,結果:[{錯誤:「 MismatchSenderId」}]}
有什麼不同? – sje397 2014-09-22 05:49:21
你的代碼是正確的。你使用正確的項目ID嗎? – Andy 2014-09-22 05:55:30
https://code.google.com/apis/console/#project:xxxxxxxxxxx請檢查 – Andy 2014-09-22 05:56:21