我已经编写了此代码来实现推送通知。但是我遇到了错误。我不知道我在哪里做错。
// API access key from Google API's Console
define( 'API_ACCESS_KEY', 'AAAADp9idX0:APA91bGHN3PP5GKS3OnVdRQgyNgx-bvAvIoR86B0e_NcZ6XP7QvLNoMiTtO54pB1PbtA3tQo5xuxmfIXD9E40oBnkXcZs9OZKSHXFASO0aH8dv7RozYuvjQXL7rguyHmuIdhOCbg' );
$registrationIds = array('62803502086');
//$registrationIds = '62803572093';
// prep the bundle
$msg = array
(
'message' => 'here is a message. message',
'title' => 'This is a title. title',
'subtitle' => 'This is a subtitle. subtitle',
'tickerText' => 'Ticker text here...Ticker text here...Ticker text here',
'vibrate' => 1,
'sound' => 1,
'largeIcon' => 'large_icon',
'smallIcon' => 'small_icon'
);
$fields = array
(
'registration_ids' => $registrationIds,
'data' => $msg
);
$headers = array
(
'Authorization: key=' . API_ACCESS_KEY,
'Content-Type: application/json'
);
$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 );
curl_setopt( $ch,CURLOPT_SSL_VERIFYPEER, false );
curl_setopt( $ch,CURLOPT_POSTFIELDS, json_encode( $fields ) );
$result = curl_exec($ch );
curl_close( $ch );
echo $result;
?>
在浏览器屏幕中出现此错误-
{“ multicast_id”:2810501046743574091,“成功”:0,“失败”:1,“ canonical_ids”:0,“结果”:[{“错误”:“ InvalidRegistration”}]}
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。