在GCM事件中解析时间戳时出错

时间:2018-10-09 18:01:13

标签: php android firebase firebase-cloud-messaging

我正在尝试向我的android发送推送通知,当推送到电话时,它显示的Error while parsing timestamp in GCM event机器人logcat使其不显示php脚本发送的数据

$url = "https://fcm.googleapis.com/fcm/send";
$token = $gcmRegIds;
$serverKey = 'AIzxxyAZ_xxxxxxx-VjxxxxxcpHqqQU';
$title = "Alert from App";
$body = $headline;
$notification = array('title' =>$title , 'body' => $body);
$data = array("timestamp"=>date('Y-m-d G:i:s'), 'id' => $new_id,'display' => 'alert');
$arrayToSend = array('registration_ids' => $token, 'notification' => $notification, 'data' => $data);
$json = json_encode($arrayToSend);
$headers = array();
$headers[] = 'Content-Type: application/json';
$headers[] = 'Authorization: key='. $serverKey;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);

curl_setopt($ch, CURLOPT_CUSTOMREQUEST,"POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
curl_setopt($ch, CURLOPT_HTTPHEADER,$headers);
//Send the request
$response = curl_exec($ch);
//Close request
if ($response === FALSE) {
die('FCM Send Error: ' . curl_error($ch));
}
curl_close($ch);
}

0 个答案:

没有答案