我的php项目中有 FCM推送通知中的一个问题。 在我的代码中我定义了不同的不同数组。当我打印我的数组给我正确的结果,所以为什么当我在浏览器中运行我的文件它给我这个错误
{"multicast_id":7882239151284835554,"success":0,"failure":1,"canonical_ids":0,"results":[{"error":"NotRegistered"}]}end
请帮帮我,谢谢。
听到我的代码
// Send Push Notification
if($user['device_token'] != '') {
$server_key = 'AAAA***********91Z9Y69';
$registrationIds = 'dLDIms************SAss';
$msg = array('body' => "Your Wait is Over!",
'title' => "New stages unlocked. Let's Play!!",
'icon' => 'myicon',/*Default Icon*/
'sound' => 'mySound'/*Default sound*/);
$fields = array('to' => $registrationIds,
'data' => $msg);
$headers = array('Authorization: key=' . $server_key,
'Content-Type: application/json');
//print_r($headers); die();
#Send Reponse To FireBase Server
$ch = curl_init();
curl_setopt( $ch,CURLOPT_URL, 'https://fcm.googleapis.com/fcm/send' );
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 ) );
$result = curl_exec($ch );
if ($result === FALSE) {
die('Curl failed: ' . curl_error($ch));
}
curl_close( $ch );
#Echo Result Of FireBase Server
echo $result;
die('end');
}