The connection was reset in gcm
I am using this code to send push notification to device
$registatoin_ids=array("DEVICE REG ID");
$message = array("product" => "shirt");
define("GOOGLE_API_KEY", "API KEY");
$url = 'https://android.googleapis.com/gcm/send';
$fields = array(
'registration_ids' => $registatoin_ids,
'data' => $message,
);
$headers = array(
'Authorization:key=' . GOOGLE_API_KEY,
'Content-Type:application/json'
);
$ch=curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
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);
if ($result === FALSE) {
die('Curl failed: ' . curl_error($ch));
}
curl_close($ch);
echo $result;
But when I try to submit, I get a "Connection has been reset" error in the browser. What could be causing this problem?
Screenshot:
Ps: Curl is running on my server.
+3
source to share
No one has answered this question yet
Check out similar questions: