1
我建設與谷歌雲消息(GCM)一個應用程序遵循文章androidexample create app to push notify發送谷歌Android雲消息(GCM)是錯誤無效註冊
但我有錯誤,當我試圖通過發送一個捲曲通知谷歌服務器與鏈接https://android.googleapis.com/gcm/send和一些領域代碼
function send_push_notification($registatoin_ids, $message) {
echo implode($registatoin_ids);
echo implode($message);
// Set POST variables
$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'
);
//print_r($headers);
// Open connection
$ch = curl_init();
//echo $ch;
// Set the url, number of POST vars, POST data
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Disabling SSL Certificate support temporarly
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
// Execute post
$result = curl_exec($ch);
if ($result === FALSE) {
echo ("RESULT ERROR :" + $ch);
die('Curl failed: ' . curl_error($ch));
}
// Close connection
curl_close($ch);
echo $result;
}
我收到的時候儘量發送
所以,能否請你幫我解決或配置來發送MESSA結果錯誤ge到服務器,我試着做一個應用程序發送通知從服務器到Android設備, 非常感謝。
PS:很抱歉,我的英語,再次感謝
歡