我有以下代码发送GCM推送通知。它工作正常。现在我刚刚将它添加到symfony动作中,但是当我请求动作时,永远不会发送推送通知。
在操作请求之后,在我的本地主机上,选项卡内的加载微调器转过来...,在我的远程主机上,我得到500错误,但我在Apache日志或symfony日志中找不到任何错误。 / p>
使用此捆绑包时遇到同样的问题:https://github.com/richsage/RMSPushNotificationsBundle
任何帮助?
$message = "the test message";
$tickerText = "ticker text message";
$contentTitle = "content title";
$contentText = "content body";
$registrationId = 'abcdef...';
$apiKey = "1234...";
$headers = array("Content-Type:" . "application/json", "Authorization:" . "key=" . $apiKey);
$data = array(
'data' => $messageData,
'registration_ids' => $registrationIdsArray
);
$ch = curl_init();
curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers );
curl_setopt( $ch, CURLOPT_URL, "https://android.googleapis.com/gcm/send" );
curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, 0 );
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, 0 );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch, CURLOPT_POSTFIELDS, json_encode($data) );
$response = curl_exec($ch);
curl_close($ch);
return $response;
答案 0 :(得分:1)
$ messageData和$ registrationIdsArray不存在。 并检查api密钥是否为浏览器api密钥。