php - Error while parsing timestamp in GCM event

337

I'm trying to send push notifications to my android, when the push comes to the phone, the android logcat it readsError while parsing timestamp in GCM event which makes it not display the data sent by the php script

$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);
}

People are also looking for solutions to the problem: SUM value in array PHP

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.