使用PHP curl通知GCM
我正在使用curl向GCM中的多个用户发送通知。 在一个场景中,如果任何用户从设备上注销/卸载了应用程序,我将从curl响应中收到失败消息UnRegistered。请使用任何其他解决方案检查registerationid是否有效并向用户发送通知 卷曲代码:使用PHP curl通知GCM,php,google-cloud-messaging,Php,Google Cloud Messaging,我正在使用curl向GCM中的多个用户发送通知。 在一个场景中,如果任何用户从设备上注销/卸载了应用程序,我将从curl响应中收到失败消息UnRegistered。请使用任何其他解决方案检查registerationid是否有效并向用户发送通知 卷曲代码: $url = 'https://android.googleapis.com/gcm/send'; $fields = array( 'registration_ids' => $registatoin_
$url = 'https://android.googleapis.com/gcm/send';
$fields = array(
'registration_ids' => $registatoin_ids,
'data' => array( "message" => $message )
);
$headers = array(
'Authorization: key=' . GOOGLE_API_KEY,
'Content-Type: application/json'
);
// Open connection
$ch = curl_init();
// Set the url, number of POST vars, POST data
curl_setopt($ch, CURLOPT_URL, $url);
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));
// Execute post
$result = curl_exec($ch);
$res = json_decode($result, true);
// Close connection
curl_close($ch);