Push-Benachrichtigung konnte nicht gesendet werden
Ich versuche eine Nachricht zu senden, erhalte aber nichts. Obwohl nein fehlschlägt, beim Drucken der Variablen:
$result
this gibt "to" zurück (ich habe keine Ahnung warum).
Der Code, den ich benutze, ist:
private function sendMessageGcm($registration_id,$message){
$this->key = "xxxxxxxxxxxxxxxxxxxxxx";
$data = array(
"registration_id" => $registration_id,
"data" => $message
);
$headers = array(
"Content-Type:application/json",
"Authorization:key=" . $this->key
);
$ch = curl_init();
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_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
$result = curl_exec($ch);
if($result == false) {
echo('Curl failed: ' . curl_error($ch));
}
curl_close($ch);
$rtn["code"] = "000";//means result OK
$rtn["msg"] = "OK";
$rtn["result"] = $result;
return($rtn);
}