Ich versuche, eine Push-Nachricht an alle Android-Nutzer meiner Anwendung zu senden. Ich kann nur an einen Benutzer senden und nicht an alle senden.Senden von Push-Nachrichten an alle Benutzer mit GCM
ist hier mein Code:
PUSH.php
<?php
// API access key from Google API's Console
define('API_ACCESS_KEY', 'my api key');
$registrationIds = array('user_push_id');
$msg = array
(
'URL' => 'http://www.apple.com/in/',
'message' => 'Did you like it ???',
'image' =>'http://icons.iconarchive.com/icons/dan-wiersma/apple-tv/128/Apple-Logo-icon.png'
);
$fields = array
(
'registration_ids' => $registrationIds,
'data' => $msg
);
$headers = array
(
'Authorization: key=' . API_ACCESS_KEY,
'Content-Type: application/json'
);
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL, 'https://android.googleapis.com/gcm/send');
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);
curl_close($ch);
echo $result;
?>
bitte helfen Sie mir, wie unten alle Benutzer von MySQL-Tabelle bekommen:
$sth = mysqli_query("SELECT PUSH_ME from push_msg_android");
$registrationIds = array();
while($r = mysqli_fetch_array($sth)) {
$registrationIds['PUSH_ID'] = $r;
}
Erhalte diesen Fehler ...................... {"multicast_id": 6112092832428284343, "Erfolg": 0, "Fehler" : 2, "canonical_ids": 0, "results": [{"Fehler": "InvalidRegistration"}, {"Fehler": "InvalidRegistration"}]} –
id - int (11) .... PUSH_ID - (Text) ..... DEVEICE_ID (Text) –
der Tabellenname ist .... push –