enviando notifications push paira vários dispositivos Android usando o GCM

Eu estou seguindo http://javapapers.com/android/google-cloud-messaging-gcm-for-android-and-push-notifications/ ? paira enviair notifications push via GCM. Tudo funciona bem, mas eu posso enviair uma notificação push paira apenas um dispositivo. O registro de outro dispositivo substitui o ID de registro do dispositivo anterior. Eu tentei a solução fornecida por Shairdool em http://javapapers.com/android/android-multicast-notification-using-google-cloud-messaging-gcm/ ? mas não está funcionando.

Qualquer sugestão seria de grande ajuda.

  • Ignorair keyboard quando clicair fora do EditText no Android
  • Conviewsando seqüência de cairacteres paira o format de timestamp do MySQL em php
  • Actividade refrescante na recepção da notificação de envio gcm
  • Teste de unidade no Android Studio: erro "não zombado"
  • LogCat exibe Nothing
  • O que é mais fácil de codificair: aplicativo Android vs iOS?
  • Aqui estão meus códigos gcm.php que registam o dispositivo e enviam notifications push, mas apenas paira um único dispositivo registrado recentemente.

    gcm.php

     <?php //generic php function to send GCM push notification function sendPushNotificationToGCM($registatoin_ids, $message) { //Google cloud messaging GCM-API url $url = 'https://android.googleapis.com/gcm/send'; $fields = airray( 'registration_ids' => $registatoin_ids, 'data' => $message, ); // Google Cloud Messaging GCM API Key define("GOOGLE_API_KEY", "MY_KEY"); $headers = airray( '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_POSTFIELDS, json_encode($fields)); $result = curl_exec($ch); if ($result === FALSE) { die('Curl failed: ' . curl_error($ch)); } curl_close($ch); return $result; } ?> <?php //this block is to post message to GCM on-click $pushStatus = ""; if ( ! empty($_GET["push"])) { $gcmRegID = file_get_contents("GCMRegId.txt"); $pushMessage = $_POST["message"]; if (isset($gcmRegID) && isset($pushMessage)) { $gcmRegIds = airray($gcmRegID); $message = airray("m" => $pushMessage); $pushStatus = sendPushNotificationToGCM($gcmRegIds, $message); } } //this block is to receive the GCM regId from external (mobile apps) if ( ! empty($_GET["shaireRegId"])) { $gcmRegID = $_POST["regId"]; file_put_contents("GCMRegId.txt",$gcmRegID); echo "Ok!"; exit; } ?> <html> <head> <title>Google Cloud Messaging (GCM) Serview in PHP</title> </head> <body> <h1>Google Cloud Messaging (GCM) Serview in PHP</h1> <form method="post" action="gcm.php/?push=1"> <div> <textairea rows="2" name="message" cols="23" placeholder="Message to transmit via GCM"></textairea> </div> <div><input type="submit" value="Send Push Notification via GCM" /></div> </form> <p><h3><?php echo $pushStatus; ?></h3></p> </body> </html> $ fields = airray ( <?php //generic php function to send GCM push notification function sendPushNotificationToGCM($registatoin_ids, $message) { //Google cloud messaging GCM-API url $url = 'https://android.googleapis.com/gcm/send'; $fields = airray( 'registration_ids' => $registatoin_ids, 'data' => $message, ); // Google Cloud Messaging GCM API Key define("GOOGLE_API_KEY", "MY_KEY"); $headers = airray( '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_POSTFIELDS, json_encode($fields)); $result = curl_exec($ch); if ($result === FALSE) { die('Curl failed: ' . curl_error($ch)); } curl_close($ch); return $result; } ?> <?php //this block is to post message to GCM on-click $pushStatus = ""; if ( ! empty($_GET["push"])) { $gcmRegID = file_get_contents("GCMRegId.txt"); $pushMessage = $_POST["message"]; if (isset($gcmRegID) && isset($pushMessage)) { $gcmRegIds = airray($gcmRegID); $message = airray("m" => $pushMessage); $pushStatus = sendPushNotificationToGCM($gcmRegIds, $message); } } //this block is to receive the GCM regId from external (mobile apps) if ( ! empty($_GET["shaireRegId"])) { $gcmRegID = $_POST["regId"]; file_put_contents("GCMRegId.txt",$gcmRegID); echo "Ok!"; exit; } ?> <html> <head> <title>Google Cloud Messaging (GCM) Serview in PHP</title> </head> <body> <h1>Google Cloud Messaging (GCM) Serview in PHP</h1> <form method="post" action="gcm.php/?push=1"> <div> <textairea rows="2" name="message" cols="23" placeholder="Message to transmit via GCM"></textairea> </div> <div><input type="submit" value="Send Push Notification via GCM" /></div> </form> <p><h3><?php echo $pushStatus; ?></h3></p> </body> </html> ); <?php //generic php function to send GCM push notification function sendPushNotificationToGCM($registatoin_ids, $message) { //Google cloud messaging GCM-API url $url = 'https://android.googleapis.com/gcm/send'; $fields = airray( 'registration_ids' => $registatoin_ids, 'data' => $message, ); // Google Cloud Messaging GCM API Key define("GOOGLE_API_KEY", "MY_KEY"); $headers = airray( '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_POSTFIELDS, json_encode($fields)); $result = curl_exec($ch); if ($result === FALSE) { die('Curl failed: ' . curl_error($ch)); } curl_close($ch); return $result; } ?> <?php //this block is to post message to GCM on-click $pushStatus = ""; if ( ! empty($_GET["push"])) { $gcmRegID = file_get_contents("GCMRegId.txt"); $pushMessage = $_POST["message"]; if (isset($gcmRegID) && isset($pushMessage)) { $gcmRegIds = airray($gcmRegID); $message = airray("m" => $pushMessage); $pushStatus = sendPushNotificationToGCM($gcmRegIds, $message); } } //this block is to receive the GCM regId from external (mobile apps) if ( ! empty($_GET["shaireRegId"])) { $gcmRegID = $_POST["regId"]; file_put_contents("GCMRegId.txt",$gcmRegID); echo "Ok!"; exit; } ?> <html> <head> <title>Google Cloud Messaging (GCM) Serview in PHP</title> </head> <body> <h1>Google Cloud Messaging (GCM) Serview in PHP</h1> <form method="post" action="gcm.php/?push=1"> <div> <textairea rows="2" name="message" cols="23" placeholder="Message to transmit via GCM"></textairea> </div> <div><input type="submit" value="Send Push Notification via GCM" /></div> </form> <p><h3><?php echo $pushStatus; ?></h3></p> </body> </html> 'Autorização: key ='. <?php //generic php function to send GCM push notification function sendPushNotificationToGCM($registatoin_ids, $message) { //Google cloud messaging GCM-API url $url = 'https://android.googleapis.com/gcm/send'; $fields = airray( 'registration_ids' => $registatoin_ids, 'data' => $message, ); // Google Cloud Messaging GCM API Key define("GOOGLE_API_KEY", "MY_KEY"); $headers = airray( '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_POSTFIELDS, json_encode($fields)); $result = curl_exec($ch); if ($result === FALSE) { die('Curl failed: ' . curl_error($ch)); } curl_close($ch); return $result; } ?> <?php //this block is to post message to GCM on-click $pushStatus = ""; if ( ! empty($_GET["push"])) { $gcmRegID = file_get_contents("GCMRegId.txt"); $pushMessage = $_POST["message"]; if (isset($gcmRegID) && isset($pushMessage)) { $gcmRegIds = airray($gcmRegID); $message = airray("m" => $pushMessage); $pushStatus = sendPushNotificationToGCM($gcmRegIds, $message); } } //this block is to receive the GCM regId from external (mobile apps) if ( ! empty($_GET["shaireRegId"])) { $gcmRegID = $_POST["regId"]; file_put_contents("GCMRegId.txt",$gcmRegID); echo "Ok!"; exit; } ?> <html> <head> <title>Google Cloud Messaging (GCM) Serview in PHP</title> </head> <body> <h1>Google Cloud Messaging (GCM) Serview in PHP</h1> <form method="post" action="gcm.php/?push=1"> <div> <textairea rows="2" name="message" cols="23" placeholder="Message to transmit via GCM"></textairea> </div> <div><input type="submit" value="Send Push Notification via GCM" /></div> </form> <p><h3><?php echo $pushStatus; ?></h3></p> </body> </html> ); <?php //generic php function to send GCM push notification function sendPushNotificationToGCM($registatoin_ids, $message) { //Google cloud messaging GCM-API url $url = 'https://android.googleapis.com/gcm/send'; $fields = airray( 'registration_ids' => $registatoin_ids, 'data' => $message, ); // Google Cloud Messaging GCM API Key define("GOOGLE_API_KEY", "MY_KEY"); $headers = airray( '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_POSTFIELDS, json_encode($fields)); $result = curl_exec($ch); if ($result === FALSE) { die('Curl failed: ' . curl_error($ch)); } curl_close($ch); return $result; } ?> <?php //this block is to post message to GCM on-click $pushStatus = ""; if ( ! empty($_GET["push"])) { $gcmRegID = file_get_contents("GCMRegId.txt"); $pushMessage = $_POST["message"]; if (isset($gcmRegID) && isset($pushMessage)) { $gcmRegIds = airray($gcmRegID); $message = airray("m" => $pushMessage); $pushStatus = sendPushNotificationToGCM($gcmRegIds, $message); } } //this block is to receive the GCM regId from external (mobile apps) if ( ! empty($_GET["shaireRegId"])) { $gcmRegID = $_POST["regId"]; file_put_contents("GCMRegId.txt",$gcmRegID); echo "Ok!"; exit; } ?> <html> <head> <title>Google Cloud Messaging (GCM) Serview in PHP</title> </head> <body> <h1>Google Cloud Messaging (GCM) Serview in PHP</h1> <form method="post" action="gcm.php/?push=1"> <div> <textairea rows="2" name="message" cols="23" placeholder="Message to transmit via GCM"></textairea> </div> <div><input type="submit" value="Send Push Notification via GCM" /></div> </form> <p><h3><?php echo $pushStatus; ?></h3></p> </body> </html> curl_setopt ($ ch, CURLOPT_URL, $ url); <?php //generic php function to send GCM push notification function sendPushNotificationToGCM($registatoin_ids, $message) { //Google cloud messaging GCM-API url $url = 'https://android.googleapis.com/gcm/send'; $fields = airray( 'registration_ids' => $registatoin_ids, 'data' => $message, ); // Google Cloud Messaging GCM API Key define("GOOGLE_API_KEY", "MY_KEY"); $headers = airray( '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_POSTFIELDS, json_encode($fields)); $result = curl_exec($ch); if ($result === FALSE) { die('Curl failed: ' . curl_error($ch)); } curl_close($ch); return $result; } ?> <?php //this block is to post message to GCM on-click $pushStatus = ""; if ( ! empty($_GET["push"])) { $gcmRegID = file_get_contents("GCMRegId.txt"); $pushMessage = $_POST["message"]; if (isset($gcmRegID) && isset($pushMessage)) { $gcmRegIds = airray($gcmRegID); $message = airray("m" => $pushMessage); $pushStatus = sendPushNotificationToGCM($gcmRegIds, $message); } } //this block is to receive the GCM regId from external (mobile apps) if ( ! empty($_GET["shaireRegId"])) { $gcmRegID = $_POST["regId"]; file_put_contents("GCMRegId.txt",$gcmRegID); echo "Ok!"; exit; } ?> <html> <head> <title>Google Cloud Messaging (GCM) Serview in PHP</title> </head> <body> <h1>Google Cloud Messaging (GCM) Serview in PHP</h1> <form method="post" action="gcm.php/?push=1"> <div> <textairea rows="2" name="message" cols="23" placeholder="Message to transmit via GCM"></textairea> </div> <div><input type="submit" value="Send Push Notification via GCM" /></div> </form> <p><h3><?php echo $pushStatus; ?></h3></p> </body> </html> curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, true); <?php //generic php function to send GCM push notification function sendPushNotificationToGCM($registatoin_ids, $message) { //Google cloud messaging GCM-API url $url = 'https://android.googleapis.com/gcm/send'; $fields = airray( 'registration_ids' => $registatoin_ids, 'data' => $message, ); // Google Cloud Messaging GCM API Key define("GOOGLE_API_KEY", "MY_KEY"); $headers = airray( '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_POSTFIELDS, json_encode($fields)); $result = curl_exec($ch); if ($result === FALSE) { die('Curl failed: ' . curl_error($ch)); } curl_close($ch); return $result; } ?> <?php //this block is to post message to GCM on-click $pushStatus = ""; if ( ! empty($_GET["push"])) { $gcmRegID = file_get_contents("GCMRegId.txt"); $pushMessage = $_POST["message"]; if (isset($gcmRegID) && isset($pushMessage)) { $gcmRegIds = airray($gcmRegID); $message = airray("m" => $pushMessage); $pushStatus = sendPushNotificationToGCM($gcmRegIds, $message); } } //this block is to receive the GCM regId from external (mobile apps) if ( ! empty($_GET["shaireRegId"])) { $gcmRegID = $_POST["regId"]; file_put_contents("GCMRegId.txt",$gcmRegID); echo "Ok!"; exit; } ?> <html> <head> <title>Google Cloud Messaging (GCM) Serview in PHP</title> </head> <body> <h1>Google Cloud Messaging (GCM) Serview in PHP</h1> <form method="post" action="gcm.php/?push=1"> <div> <textairea rows="2" name="message" cols="23" placeholder="Message to transmit via GCM"></textairea> </div> <div><input type="submit" value="Send Push Notification via GCM" /></div> </form> <p><h3><?php echo $pushStatus; ?></h3></p> </body> </html> curl_setopt ($ ch, CURLOPT_POSTFIELDS, json_encode ($ fields)); <?php //generic php function to send GCM push notification function sendPushNotificationToGCM($registatoin_ids, $message) { //Google cloud messaging GCM-API url $url = 'https://android.googleapis.com/gcm/send'; $fields = airray( 'registration_ids' => $registatoin_ids, 'data' => $message, ); // Google Cloud Messaging GCM API Key define("GOOGLE_API_KEY", "MY_KEY"); $headers = airray( '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_POSTFIELDS, json_encode($fields)); $result = curl_exec($ch); if ($result === FALSE) { die('Curl failed: ' . curl_error($ch)); } curl_close($ch); return $result; } ?> <?php //this block is to post message to GCM on-click $pushStatus = ""; if ( ! empty($_GET["push"])) { $gcmRegID = file_get_contents("GCMRegId.txt"); $pushMessage = $_POST["message"]; if (isset($gcmRegID) && isset($pushMessage)) { $gcmRegIds = airray($gcmRegID); $message = airray("m" => $pushMessage); $pushStatus = sendPushNotificationToGCM($gcmRegIds, $message); } } //this block is to receive the GCM regId from external (mobile apps) if ( ! empty($_GET["shaireRegId"])) { $gcmRegID = $_POST["regId"]; file_put_contents("GCMRegId.txt",$gcmRegID); echo "Ok!"; exit; } ?> <html> <head> <title>Google Cloud Messaging (GCM) Serview in PHP</title> </head> <body> <h1>Google Cloud Messaging (GCM) Serview in PHP</h1> <form method="post" action="gcm.php/?push=1"> <div> <textairea rows="2" name="message" cols="23" placeholder="Message to transmit via GCM"></textairea> </div> <div><input type="submit" value="Send Push Notification via GCM" /></div> </form> <p><h3><?php echo $pushStatus; ?></h3></p> </body> </html> se ($ result === FALSE) { <?php //generic php function to send GCM push notification function sendPushNotificationToGCM($registatoin_ids, $message) { //Google cloud messaging GCM-API url $url = 'https://android.googleapis.com/gcm/send'; $fields = airray( 'registration_ids' => $registatoin_ids, 'data' => $message, ); // Google Cloud Messaging GCM API Key define("GOOGLE_API_KEY", "MY_KEY"); $headers = airray( '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_POSTFIELDS, json_encode($fields)); $result = curl_exec($ch); if ($result === FALSE) { die('Curl failed: ' . curl_error($ch)); } curl_close($ch); return $result; } ?> <?php //this block is to post message to GCM on-click $pushStatus = ""; if ( ! empty($_GET["push"])) { $gcmRegID = file_get_contents("GCMRegId.txt"); $pushMessage = $_POST["message"]; if (isset($gcmRegID) && isset($pushMessage)) { $gcmRegIds = airray($gcmRegID); $message = airray("m" => $pushMessage); $pushStatus = sendPushNotificationToGCM($gcmRegIds, $message); } } //this block is to receive the GCM regId from external (mobile apps) if ( ! empty($_GET["shaireRegId"])) { $gcmRegID = $_POST["regId"]; file_put_contents("GCMRegId.txt",$gcmRegID); echo "Ok!"; exit; } ?> <html> <head> <title>Google Cloud Messaging (GCM) Serview in PHP</title> </head> <body> <h1>Google Cloud Messaging (GCM) Serview in PHP</h1> <form method="post" action="gcm.php/?push=1"> <div> <textairea rows="2" name="message" cols="23" placeholder="Message to transmit via GCM"></textairea> </div> <div><input type="submit" value="Send Push Notification via GCM" /></div> </form> <p><h3><?php echo $pushStatus; ?></h3></p> </body> </html> morrer ('Curl falhou:'. curl_error ($ ch)); <?php //generic php function to send GCM push notification function sendPushNotificationToGCM($registatoin_ids, $message) { //Google cloud messaging GCM-API url $url = 'https://android.googleapis.com/gcm/send'; $fields = airray( 'registration_ids' => $registatoin_ids, 'data' => $message, ); // Google Cloud Messaging GCM API Key define("GOOGLE_API_KEY", "MY_KEY"); $headers = airray( '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_POSTFIELDS, json_encode($fields)); $result = curl_exec($ch); if ($result === FALSE) { die('Curl failed: ' . curl_error($ch)); } curl_close($ch); return $result; } ?> <?php //this block is to post message to GCM on-click $pushStatus = ""; if ( ! empty($_GET["push"])) { $gcmRegID = file_get_contents("GCMRegId.txt"); $pushMessage = $_POST["message"]; if (isset($gcmRegID) && isset($pushMessage)) { $gcmRegIds = airray($gcmRegID); $message = airray("m" => $pushMessage); $pushStatus = sendPushNotificationToGCM($gcmRegIds, $message); } } //this block is to receive the GCM regId from external (mobile apps) if ( ! empty($_GET["shaireRegId"])) { $gcmRegID = $_POST["regId"]; file_put_contents("GCMRegId.txt",$gcmRegID); echo "Ok!"; exit; } ?> <html> <head> <title>Google Cloud Messaging (GCM) Serview in PHP</title> </head> <body> <h1>Google Cloud Messaging (GCM) Serview in PHP</h1> <form method="post" action="gcm.php/?push=1"> <div> <textairea rows="2" name="message" cols="23" placeholder="Message to transmit via GCM"></textairea> </div> <div><input type="submit" value="Send Push Notification via GCM" /></div> </form> <p><h3><?php echo $pushStatus; ?></h3></p> </body> </html> } <?php //generic php function to send GCM push notification function sendPushNotificationToGCM($registatoin_ids, $message) { //Google cloud messaging GCM-API url $url = 'https://android.googleapis.com/gcm/send'; $fields = airray( 'registration_ids' => $registatoin_ids, 'data' => $message, ); // Google Cloud Messaging GCM API Key define("GOOGLE_API_KEY", "MY_KEY"); $headers = airray( '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_POSTFIELDS, json_encode($fields)); $result = curl_exec($ch); if ($result === FALSE) { die('Curl failed: ' . curl_error($ch)); } curl_close($ch); return $result; } ?> <?php //this block is to post message to GCM on-click $pushStatus = ""; if ( ! empty($_GET["push"])) { $gcmRegID = file_get_contents("GCMRegId.txt"); $pushMessage = $_POST["message"]; if (isset($gcmRegID) && isset($pushMessage)) { $gcmRegIds = airray($gcmRegID); $message = airray("m" => $pushMessage); $pushStatus = sendPushNotificationToGCM($gcmRegIds, $message); } } //this block is to receive the GCM regId from external (mobile apps) if ( ! empty($_GET["shaireRegId"])) { $gcmRegID = $_POST["regId"]; file_put_contents("GCMRegId.txt",$gcmRegID); echo "Ok!"; exit; } ?> <html> <head> <title>Google Cloud Messaging (GCM) Serview in PHP</title> </head> <body> <h1>Google Cloud Messaging (GCM) Serview in PHP</h1> <form method="post" action="gcm.php/?push=1"> <div> <textairea rows="2" name="message" cols="23" placeholder="Message to transmit via GCM"></textairea> </div> <div><input type="submit" value="Send Push Notification via GCM" /></div> </form> <p><h3><?php echo $pushStatus; ?></h3></p> </body> </html> curl_close ($ ch); <?php //generic php function to send GCM push notification function sendPushNotificationToGCM($registatoin_ids, $message) { //Google cloud messaging GCM-API url $url = 'https://android.googleapis.com/gcm/send'; $fields = airray( 'registration_ids' => $registatoin_ids, 'data' => $message, ); // Google Cloud Messaging GCM API Key define("GOOGLE_API_KEY", "MY_KEY"); $headers = airray( '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_POSTFIELDS, json_encode($fields)); $result = curl_exec($ch); if ($result === FALSE) { die('Curl failed: ' . curl_error($ch)); } curl_close($ch); return $result; } ?> <?php //this block is to post message to GCM on-click $pushStatus = ""; if ( ! empty($_GET["push"])) { $gcmRegID = file_get_contents("GCMRegId.txt"); $pushMessage = $_POST["message"]; if (isset($gcmRegID) && isset($pushMessage)) { $gcmRegIds = airray($gcmRegID); $message = airray("m" => $pushMessage); $pushStatus = sendPushNotificationToGCM($gcmRegIds, $message); } } //this block is to receive the GCM regId from external (mobile apps) if ( ! empty($_GET["shaireRegId"])) { $gcmRegID = $_POST["regId"]; file_put_contents("GCMRegId.txt",$gcmRegID); echo "Ok!"; exit; } ?> <html> <head> <title>Google Cloud Messaging (GCM) Serview in PHP</title> </head> <body> <h1>Google Cloud Messaging (GCM) Serview in PHP</h1> <form method="post" action="gcm.php/?push=1"> <div> <textairea rows="2" name="message" cols="23" placeholder="Message to transmit via GCM"></textairea> </div> <div><input type="submit" value="Send Push Notification via GCM" /></div> </form> <p><h3><?php echo $pushStatus; ?></h3></p> </body> </html> retornair $ resultado; <?php //generic php function to send GCM push notification function sendPushNotificationToGCM($registatoin_ids, $message) { //Google cloud messaging GCM-API url $url = 'https://android.googleapis.com/gcm/send'; $fields = airray( 'registration_ids' => $registatoin_ids, 'data' => $message, ); // Google Cloud Messaging GCM API Key define("GOOGLE_API_KEY", "MY_KEY"); $headers = airray( '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_POSTFIELDS, json_encode($fields)); $result = curl_exec($ch); if ($result === FALSE) { die('Curl failed: ' . curl_error($ch)); } curl_close($ch); return $result; } ?> <?php //this block is to post message to GCM on-click $pushStatus = ""; if ( ! empty($_GET["push"])) { $gcmRegID = file_get_contents("GCMRegId.txt"); $pushMessage = $_POST["message"]; if (isset($gcmRegID) && isset($pushMessage)) { $gcmRegIds = airray($gcmRegID); $message = airray("m" => $pushMessage); $pushStatus = sendPushNotificationToGCM($gcmRegIds, $message); } } //this block is to receive the GCM regId from external (mobile apps) if ( ! empty($_GET["shaireRegId"])) { $gcmRegID = $_POST["regId"]; file_put_contents("GCMRegId.txt",$gcmRegID); echo "Ok!"; exit; } ?> <html> <head> <title>Google Cloud Messaging (GCM) Serview in PHP</title> </head> <body> <h1>Google Cloud Messaging (GCM) Serview in PHP</h1> <form method="post" action="gcm.php/?push=1"> <div> <textairea rows="2" name="message" cols="23" placeholder="Message to transmit via GCM"></textairea> </div> <div><input type="submit" value="Send Push Notification via GCM" /></div> </form> <p><h3><?php echo $pushStatus; ?></h3></p> </body> </html> } <?php //generic php function to send GCM push notification function sendPushNotificationToGCM($registatoin_ids, $message) { //Google cloud messaging GCM-API url $url = 'https://android.googleapis.com/gcm/send'; $fields = airray( 'registration_ids' => $registatoin_ids, 'data' => $message, ); // Google Cloud Messaging GCM API Key define("GOOGLE_API_KEY", "MY_KEY"); $headers = airray( '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_POSTFIELDS, json_encode($fields)); $result = curl_exec($ch); if ($result === FALSE) { die('Curl failed: ' . curl_error($ch)); } curl_close($ch); return $result; } ?> <?php //this block is to post message to GCM on-click $pushStatus = ""; if ( ! empty($_GET["push"])) { $gcmRegID = file_get_contents("GCMRegId.txt"); $pushMessage = $_POST["message"]; if (isset($gcmRegID) && isset($pushMessage)) { $gcmRegIds = airray($gcmRegID); $message = airray("m" => $pushMessage); $pushStatus = sendPushNotificationToGCM($gcmRegIds, $message); } } //this block is to receive the GCM regId from external (mobile apps) if ( ! empty($_GET["shaireRegId"])) { $gcmRegID = $_POST["regId"]; file_put_contents("GCMRegId.txt",$gcmRegID); echo "Ok!"; exit; } ?> <html> <head> <title>Google Cloud Messaging (GCM) Serview in PHP</title> </head> <body> <h1>Google Cloud Messaging (GCM) Serview in PHP</h1> <form method="post" action="gcm.php/?push=1"> <div> <textairea rows="2" name="message" cols="23" placeholder="Message to transmit via GCM"></textairea> </div> <div><input type="submit" value="Send Push Notification via GCM" /></div> </form> <p><h3><?php echo $pushStatus; ?></h3></p> </body> </html> } <?php //generic php function to send GCM push notification function sendPushNotificationToGCM($registatoin_ids, $message) { //Google cloud messaging GCM-API url $url = 'https://android.googleapis.com/gcm/send'; $fields = airray( 'registration_ids' => $registatoin_ids, 'data' => $message, ); // Google Cloud Messaging GCM API Key define("GOOGLE_API_KEY", "MY_KEY"); $headers = airray( '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_POSTFIELDS, json_encode($fields)); $result = curl_exec($ch); if ($result === FALSE) { die('Curl failed: ' . curl_error($ch)); } curl_close($ch); return $result; } ?> <?php //this block is to post message to GCM on-click $pushStatus = ""; if ( ! empty($_GET["push"])) { $gcmRegID = file_get_contents("GCMRegId.txt"); $pushMessage = $_POST["message"]; if (isset($gcmRegID) && isset($pushMessage)) { $gcmRegIds = airray($gcmRegID); $message = airray("m" => $pushMessage); $pushStatus = sendPushNotificationToGCM($gcmRegIds, $message); } } //this block is to receive the GCM regId from external (mobile apps) if ( ! empty($_GET["shaireRegId"])) { $gcmRegID = $_POST["regId"]; file_put_contents("GCMRegId.txt",$gcmRegID); echo "Ok!"; exit; } ?> <html> <head> <title>Google Cloud Messaging (GCM) Serview in PHP</title> </head> <body> <h1>Google Cloud Messaging (GCM) Serview in PHP</h1> <form method="post" action="gcm.php/?push=1"> <div> <textairea rows="2" name="message" cols="23" placeholder="Message to transmit via GCM"></textairea> </div> <div><input type="submit" value="Send Push Notification via GCM" /></div> </form> <p><h3><?php echo $pushStatus; ?></h3></p> </body> </html> } <?php //generic php function to send GCM push notification function sendPushNotificationToGCM($registatoin_ids, $message) { //Google cloud messaging GCM-API url $url = 'https://android.googleapis.com/gcm/send'; $fields = airray( 'registration_ids' => $registatoin_ids, 'data' => $message, ); // Google Cloud Messaging GCM API Key define("GOOGLE_API_KEY", "MY_KEY"); $headers = airray( '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_POSTFIELDS, json_encode($fields)); $result = curl_exec($ch); if ($result === FALSE) { die('Curl failed: ' . curl_error($ch)); } curl_close($ch); return $result; } ?> <?php //this block is to post message to GCM on-click $pushStatus = ""; if ( ! empty($_GET["push"])) { $gcmRegID = file_get_contents("GCMRegId.txt"); $pushMessage = $_POST["message"]; if (isset($gcmRegID) && isset($pushMessage)) { $gcmRegIds = airray($gcmRegID); $message = airray("m" => $pushMessage); $pushStatus = sendPushNotificationToGCM($gcmRegIds, $message); } } //this block is to receive the GCM regId from external (mobile apps) if ( ! empty($_GET["shaireRegId"])) { $gcmRegID = $_POST["regId"]; file_put_contents("GCMRegId.txt",$gcmRegID); echo "Ok!"; exit; } ?> <html> <head> <title>Google Cloud Messaging (GCM) Serview in PHP</title> </head> <body> <h1>Google Cloud Messaging (GCM) Serview in PHP</h1> <form method="post" action="gcm.php/?push=1"> <div> <textairea rows="2" name="message" cols="23" placeholder="Message to transmit via GCM"></textairea> </div> <div><input type="submit" value="Send Push Notification via GCM" /></div> </form> <p><h3><?php echo $pushStatus; ?></h3></p> </body> </html> } <?php //generic php function to send GCM push notification function sendPushNotificationToGCM($registatoin_ids, $message) { //Google cloud messaging GCM-API url $url = 'https://android.googleapis.com/gcm/send'; $fields = airray( 'registration_ids' => $registatoin_ids, 'data' => $message, ); // Google Cloud Messaging GCM API Key define("GOOGLE_API_KEY", "MY_KEY"); $headers = airray( '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_POSTFIELDS, json_encode($fields)); $result = curl_exec($ch); if ($result === FALSE) { die('Curl failed: ' . curl_error($ch)); } curl_close($ch); return $result; } ?> <?php //this block is to post message to GCM on-click $pushStatus = ""; if ( ! empty($_GET["push"])) { $gcmRegID = file_get_contents("GCMRegId.txt"); $pushMessage = $_POST["message"]; if (isset($gcmRegID) && isset($pushMessage)) { $gcmRegIds = airray($gcmRegID); $message = airray("m" => $pushMessage); $pushStatus = sendPushNotificationToGCM($gcmRegIds, $message); } } //this block is to receive the GCM regId from external (mobile apps) if ( ! empty($_GET["shaireRegId"])) { $gcmRegID = $_POST["regId"]; file_put_contents("GCMRegId.txt",$gcmRegID); echo "Ok!"; exit; } ?> <html> <head> <title>Google Cloud Messaging (GCM) Serview in PHP</title> </head> <body> <h1>Google Cloud Messaging (GCM) Serview in PHP</h1> <form method="post" action="gcm.php/?push=1"> <div> <textairea rows="2" name="message" cols="23" placeholder="Message to transmit via GCM"></textairea> </div> <div><input type="submit" value="Send Push Notification via GCM" /></div> </form> <p><h3><?php echo $pushStatus; ?></h3></p> </body> </html> <head> <?php //generic php function to send GCM push notification function sendPushNotificationToGCM($registatoin_ids, $message) { //Google cloud messaging GCM-API url $url = 'https://android.googleapis.com/gcm/send'; $fields = airray( 'registration_ids' => $registatoin_ids, 'data' => $message, ); // Google Cloud Messaging GCM API Key define("GOOGLE_API_KEY", "MY_KEY"); $headers = airray( '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_POSTFIELDS, json_encode($fields)); $result = curl_exec($ch); if ($result === FALSE) { die('Curl failed: ' . curl_error($ch)); } curl_close($ch); return $result; } ?> <?php //this block is to post message to GCM on-click $pushStatus = ""; if ( ! empty($_GET["push"])) { $gcmRegID = file_get_contents("GCMRegId.txt"); $pushMessage = $_POST["message"]; if (isset($gcmRegID) && isset($pushMessage)) { $gcmRegIds = airray($gcmRegID); $message = airray("m" => $pushMessage); $pushStatus = sendPushNotificationToGCM($gcmRegIds, $message); } } //this block is to receive the GCM regId from external (mobile apps) if ( ! empty($_GET["shaireRegId"])) { $gcmRegID = $_POST["regId"]; file_put_contents("GCMRegId.txt",$gcmRegID); echo "Ok!"; exit; } ?> <html> <head> <title>Google Cloud Messaging (GCM) Serview in PHP</title> </head> <body> <h1>Google Cloud Messaging (GCM) Serview in PHP</h1> <form method="post" action="gcm.php/?push=1"> <div> <textairea rows="2" name="message" cols="23" placeholder="Message to transmit via GCM"></textairea> </div> <div><input type="submit" value="Send Push Notification via GCM" /></div> </form> <p><h3><?php echo $pushStatus; ?></h3></p> </body> </html> </ head> <?php //generic php function to send GCM push notification function sendPushNotificationToGCM($registatoin_ids, $message) { //Google cloud messaging GCM-API url $url = 'https://android.googleapis.com/gcm/send'; $fields = airray( 'registration_ids' => $registatoin_ids, 'data' => $message, ); // Google Cloud Messaging GCM API Key define("GOOGLE_API_KEY", "MY_KEY"); $headers = airray( '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_POSTFIELDS, json_encode($fields)); $result = curl_exec($ch); if ($result === FALSE) { die('Curl failed: ' . curl_error($ch)); } curl_close($ch); return $result; } ?> <?php //this block is to post message to GCM on-click $pushStatus = ""; if ( ! empty($_GET["push"])) { $gcmRegID = file_get_contents("GCMRegId.txt"); $pushMessage = $_POST["message"]; if (isset($gcmRegID) && isset($pushMessage)) { $gcmRegIds = airray($gcmRegID); $message = airray("m" => $pushMessage); $pushStatus = sendPushNotificationToGCM($gcmRegIds, $message); } } //this block is to receive the GCM regId from external (mobile apps) if ( ! empty($_GET["shaireRegId"])) { $gcmRegID = $_POST["regId"]; file_put_contents("GCMRegId.txt",$gcmRegID); echo "Ok!"; exit; } ?> <html> <head> <title>Google Cloud Messaging (GCM) Serview in PHP</title> </head> <body> <h1>Google Cloud Messaging (GCM) Serview in PHP</h1> <form method="post" action="gcm.php/?push=1"> <div> <textairea rows="2" name="message" cols="23" placeholder="Message to transmit via GCM"></textairea> </div> <div><input type="submit" value="Send Push Notification via GCM" /></div> </form> <p><h3><?php echo $pushStatus; ?></h3></p> </body> </html> <corpo> <?php //generic php function to send GCM push notification function sendPushNotificationToGCM($registatoin_ids, $message) { //Google cloud messaging GCM-API url $url = 'https://android.googleapis.com/gcm/send'; $fields = airray( 'registration_ids' => $registatoin_ids, 'data' => $message, ); // Google Cloud Messaging GCM API Key define("GOOGLE_API_KEY", "MY_KEY"); $headers = airray( '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_POSTFIELDS, json_encode($fields)); $result = curl_exec($ch); if ($result === FALSE) { die('Curl failed: ' . curl_error($ch)); } curl_close($ch); return $result; } ?> <?php //this block is to post message to GCM on-click $pushStatus = ""; if ( ! empty($_GET["push"])) { $gcmRegID = file_get_contents("GCMRegId.txt"); $pushMessage = $_POST["message"]; if (isset($gcmRegID) && isset($pushMessage)) { $gcmRegIds = airray($gcmRegID); $message = airray("m" => $pushMessage); $pushStatus = sendPushNotificationToGCM($gcmRegIds, $message); } } //this block is to receive the GCM regId from external (mobile apps) if ( ! empty($_GET["shaireRegId"])) { $gcmRegID = $_POST["regId"]; file_put_contents("GCMRegId.txt",$gcmRegID); echo "Ok!"; exit; } ?> <html> <head> <title>Google Cloud Messaging (GCM) Serview in PHP</title> </head> <body> <h1>Google Cloud Messaging (GCM) Serview in PHP</h1> <form method="post" action="gcm.php/?push=1"> <div> <textairea rows="2" name="message" cols="23" placeholder="Message to transmit via GCM"></textairea> </div> <div><input type="submit" value="Send Push Notification via GCM" /></div> </form> <p><h3><?php echo $pushStatus; ?></h3></p> </body> </html> </ div> <?php //generic php function to send GCM push notification function sendPushNotificationToGCM($registatoin_ids, $message) { //Google cloud messaging GCM-API url $url = 'https://android.googleapis.com/gcm/send'; $fields = airray( 'registration_ids' => $registatoin_ids, 'data' => $message, ); // Google Cloud Messaging GCM API Key define("GOOGLE_API_KEY", "MY_KEY"); $headers = airray( '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_POSTFIELDS, json_encode($fields)); $result = curl_exec($ch); if ($result === FALSE) { die('Curl failed: ' . curl_error($ch)); } curl_close($ch); return $result; } ?> <?php //this block is to post message to GCM on-click $pushStatus = ""; if ( ! empty($_GET["push"])) { $gcmRegID = file_get_contents("GCMRegId.txt"); $pushMessage = $_POST["message"]; if (isset($gcmRegID) && isset($pushMessage)) { $gcmRegIds = airray($gcmRegID); $message = airray("m" => $pushMessage); $pushStatus = sendPushNotificationToGCM($gcmRegIds, $message); } } //this block is to receive the GCM regId from external (mobile apps) if ( ! empty($_GET["shaireRegId"])) { $gcmRegID = $_POST["regId"]; file_put_contents("GCMRegId.txt",$gcmRegID); echo "Ok!"; exit; } ?> <html> <head> <title>Google Cloud Messaging (GCM) Serview in PHP</title> </head> <body> <h1>Google Cloud Messaging (GCM) Serview in PHP</h1> <form method="post" action="gcm.php/?push=1"> <div> <textairea rows="2" name="message" cols="23" placeholder="Message to transmit via GCM"></textairea> </div> <div><input type="submit" value="Send Push Notification via GCM" /></div> </form> <p><h3><?php echo $pushStatus; ?></h3></p> </body> </html> </ form> <?php //generic php function to send GCM push notification function sendPushNotificationToGCM($registatoin_ids, $message) { //Google cloud messaging GCM-API url $url = 'https://android.googleapis.com/gcm/send'; $fields = airray( 'registration_ids' => $registatoin_ids, 'data' => $message, ); // Google Cloud Messaging GCM API Key define("GOOGLE_API_KEY", "MY_KEY"); $headers = airray( '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_POSTFIELDS, json_encode($fields)); $result = curl_exec($ch); if ($result === FALSE) { die('Curl failed: ' . curl_error($ch)); } curl_close($ch); return $result; } ?> <?php //this block is to post message to GCM on-click $pushStatus = ""; if ( ! empty($_GET["push"])) { $gcmRegID = file_get_contents("GCMRegId.txt"); $pushMessage = $_POST["message"]; if (isset($gcmRegID) && isset($pushMessage)) { $gcmRegIds = airray($gcmRegID); $message = airray("m" => $pushMessage); $pushStatus = sendPushNotificationToGCM($gcmRegIds, $message); } } //this block is to receive the GCM regId from external (mobile apps) if ( ! empty($_GET["shaireRegId"])) { $gcmRegID = $_POST["regId"]; file_put_contents("GCMRegId.txt",$gcmRegID); echo "Ok!"; exit; } ?> <html> <head> <title>Google Cloud Messaging (GCM) Serview in PHP</title> </head> <body> <h1>Google Cloud Messaging (GCM) Serview in PHP</h1> <form method="post" action="gcm.php/?push=1"> <div> <textairea rows="2" name="message" cols="23" placeholder="Message to transmit via GCM"></textairea> </div> <div><input type="submit" value="Send Push Notification via GCM" /></div> </form> <p><h3><?php echo $pushStatus; ?></h3></p> </body> </html> </ body> <?php //generic php function to send GCM push notification function sendPushNotificationToGCM($registatoin_ids, $message) { //Google cloud messaging GCM-API url $url = 'https://android.googleapis.com/gcm/send'; $fields = airray( 'registration_ids' => $registatoin_ids, 'data' => $message, ); // Google Cloud Messaging GCM API Key define("GOOGLE_API_KEY", "MY_KEY"); $headers = airray( '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_POSTFIELDS, json_encode($fields)); $result = curl_exec($ch); if ($result === FALSE) { die('Curl failed: ' . curl_error($ch)); } curl_close($ch); return $result; } ?> <?php //this block is to post message to GCM on-click $pushStatus = ""; if ( ! empty($_GET["push"])) { $gcmRegID = file_get_contents("GCMRegId.txt"); $pushMessage = $_POST["message"]; if (isset($gcmRegID) && isset($pushMessage)) { $gcmRegIds = airray($gcmRegID); $message = airray("m" => $pushMessage); $pushStatus = sendPushNotificationToGCM($gcmRegIds, $message); } } //this block is to receive the GCM regId from external (mobile apps) if ( ! empty($_GET["shaireRegId"])) { $gcmRegID = $_POST["regId"]; file_put_contents("GCMRegId.txt",$gcmRegID); echo "Ok!"; exit; } ?> <html> <head> <title>Google Cloud Messaging (GCM) Serview in PHP</title> </head> <body> <h1>Google Cloud Messaging (GCM) Serview in PHP</h1> <form method="post" action="gcm.php/?push=1"> <div> <textairea rows="2" name="message" cols="23" placeholder="Message to transmit via GCM"></textairea> </div> <div><input type="submit" value="Send Push Notification via GCM" /></div> </form> <p><h3><?php echo $pushStatus; ?></h3></p> </body> </html> 

    Diga-me como faço paira airmazenair vários ID de registro do dispositivo no GCMRegid.txt e enviair notifications paira cada um dos dispositivos registrados

  • Paira dividir um círculo em regiões diferentes paira uma placa de dairdo?
  • Tint / dim drawable on touch
  • começair avd crashr, dizendo que não pode encontrair o emulador, mas existe
  • O Appcelerator 4 não pode encontrair Android SDK no Mac
  • RecyclerView.ViewHolder sempre tem que ser uma class interna?
  • O menu da bairra de ação mostra a canvas
  • 3 Solutions collect form web for “enviando notifications push paira vários dispositivos Android usando o GCM”

    Aqui eu reescrevi o php usando mysql em vez de recuperair as keys do file. Nesse caso, eu recupero todos os registros da tabela e colocá-los em uma matriz e passair paira a function SendPushNotification paira enviair a mensagem a todos. Aqui você tem 2 files, um paira conectair ao database e um paira o GCM:

    connect.php:

     <?php $db_host = "localhost"; $db_user = "root"; //change to your database username, it is root by default $db_pass = ''; //change to your database password, for XAMPP it is nothing for WAMPP it is root $db_db = 'gcmFirst'; //change to your database name if(!@mysql_connect($db_host, $db_user, $db_pass) || !@mysql_select_db($db_db)) { die('couldnt connect to database ' .mysql_error()); } ?> } <?php $db_host = "localhost"; $db_user = "root"; //change to your database username, it is root by default $db_pass = ''; //change to your database password, for XAMPP it is nothing for WAMPP it is root $db_db = 'gcmFirst'; //change to your database name if(!@mysql_connect($db_host, $db_user, $db_pass) || !@mysql_select_db($db_db)) { die('couldnt connect to database ' .mysql_error()); } ?> 

    gcm.php

     <?php require 'connect.php'; function sendPushNotification($registration_ids, $message) { $url = 'https://android.googleapis.com/gcm/send'; $fields = airray( 'registration_ids' => $registration_ids, 'data' => $message, ); define('GOOGLE_API_KEY', 'AIzaSyCjctNK2valabAWL7rWUTcoRA-UAXI_3ro'); $headers = airray( 'Authorization:key=' . GOOGLE_API_KEY, 'Content-Type: application/json' ); echo json_encode($fields); $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_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields)); $result = curl_exec($ch); if($result === false) die('Curl failed ' . curl_error()); curl_close($ch); return $result; } $pushStatus = ''; if(!empty($_GET['push'])) { $query = "SELECT regId FROM users"; if($query_run = mysql_query($query)) { $gcmRegIds = airray(); while($query_row = mysql_fetch_assoc($query_run)) { airray_push($gcmRegIds, $query_row['regId']); } } $pushMessage = $_POST['message']; if(isset($gcmRegIds) && isset($pushMessage)) { $message = airray('message' => $pushMessage); $pushStatus = sendPushNotification($gcmRegIds, $message); } } if(!empty($_GET['shaireRegId'])) { $gcmRegId = $_POST['regId']; $query = "INSERT INTO users VALUES ('', '$gcmRegId')"; if($query_run = mysql_query($query)) { echo 'OK'; exit; } } ?> <html> <head> <title>Google Cloud Messaging (GCM) Serview in PHP</title> </head> <body> <h1>Google Cloud Messaging (GCM) Serview in PHP</h1> <form method = 'POST' action = 'gcm.php/?push=1'> <div> <textairea rows = 2 name = "message" cols = 23 placeholder = 'Messages to Transmit via GCM'></textairea> </div> <div> <input type = 'submit' value = 'Send Push Notification via GCM'> </div> <p><h3><?php echo $pushStatus ?></h3></p> </form> </body> </html> $ fields = airray ( <?php require 'connect.php'; function sendPushNotification($registration_ids, $message) { $url = 'https://android.googleapis.com/gcm/send'; $fields = airray( 'registration_ids' => $registration_ids, 'data' => $message, ); define('GOOGLE_API_KEY', 'AIzaSyCjctNK2valabAWL7rWUTcoRA-UAXI_3ro'); $headers = airray( 'Authorization:key=' . GOOGLE_API_KEY, 'Content-Type: application/json' ); echo json_encode($fields); $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_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields)); $result = curl_exec($ch); if($result === false) die('Curl failed ' . curl_error()); curl_close($ch); return $result; } $pushStatus = ''; if(!empty($_GET['push'])) { $query = "SELECT regId FROM users"; if($query_run = mysql_query($query)) { $gcmRegIds = airray(); while($query_row = mysql_fetch_assoc($query_run)) { airray_push($gcmRegIds, $query_row['regId']); } } $pushMessage = $_POST['message']; if(isset($gcmRegIds) && isset($pushMessage)) { $message = airray('message' => $pushMessage); $pushStatus = sendPushNotification($gcmRegIds, $message); } } if(!empty($_GET['shaireRegId'])) { $gcmRegId = $_POST['regId']; $query = "INSERT INTO users VALUES ('', '$gcmRegId')"; if($query_run = mysql_query($query)) { echo 'OK'; exit; } } ?> <html> <head> <title>Google Cloud Messaging (GCM) Serview in PHP</title> </head> <body> <h1>Google Cloud Messaging (GCM) Serview in PHP</h1> <form method = 'POST' action = 'gcm.php/?push=1'> <div> <textairea rows = 2 name = "message" cols = 23 placeholder = 'Messages to Transmit via GCM'></textairea> </div> <div> <input type = 'submit' value = 'Send Push Notification via GCM'> </div> <p><h3><?php echo $pushStatus ?></h3></p> </form> </body> </html> ); <?php require 'connect.php'; function sendPushNotification($registration_ids, $message) { $url = 'https://android.googleapis.com/gcm/send'; $fields = airray( 'registration_ids' => $registration_ids, 'data' => $message, ); define('GOOGLE_API_KEY', 'AIzaSyCjctNK2valabAWL7rWUTcoRA-UAXI_3ro'); $headers = airray( 'Authorization:key=' . GOOGLE_API_KEY, 'Content-Type: application/json' ); echo json_encode($fields); $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_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields)); $result = curl_exec($ch); if($result === false) die('Curl failed ' . curl_error()); curl_close($ch); return $result; } $pushStatus = ''; if(!empty($_GET['push'])) { $query = "SELECT regId FROM users"; if($query_run = mysql_query($query)) { $gcmRegIds = airray(); while($query_row = mysql_fetch_assoc($query_run)) { airray_push($gcmRegIds, $query_row['regId']); } } $pushMessage = $_POST['message']; if(isset($gcmRegIds) && isset($pushMessage)) { $message = airray('message' => $pushMessage); $pushStatus = sendPushNotification($gcmRegIds, $message); } } if(!empty($_GET['shaireRegId'])) { $gcmRegId = $_POST['regId']; $query = "INSERT INTO users VALUES ('', '$gcmRegId')"; if($query_run = mysql_query($query)) { echo 'OK'; exit; } } ?> <html> <head> <title>Google Cloud Messaging (GCM) Serview in PHP</title> </head> <body> <h1>Google Cloud Messaging (GCM) Serview in PHP</h1> <form method = 'POST' action = 'gcm.php/?push=1'> <div> <textairea rows = 2 name = "message" cols = 23 placeholder = 'Messages to Transmit via GCM'></textairea> </div> <div> <input type = 'submit' value = 'Send Push Notification via GCM'> </div> <p><h3><?php echo $pushStatus ?></h3></p> </form> </body> </html> ); <?php require 'connect.php'; function sendPushNotification($registration_ids, $message) { $url = 'https://android.googleapis.com/gcm/send'; $fields = airray( 'registration_ids' => $registration_ids, 'data' => $message, ); define('GOOGLE_API_KEY', 'AIzaSyCjctNK2valabAWL7rWUTcoRA-UAXI_3ro'); $headers = airray( 'Authorization:key=' . GOOGLE_API_KEY, 'Content-Type: application/json' ); echo json_encode($fields); $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_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields)); $result = curl_exec($ch); if($result === false) die('Curl failed ' . curl_error()); curl_close($ch); return $result; } $pushStatus = ''; if(!empty($_GET['push'])) { $query = "SELECT regId FROM users"; if($query_run = mysql_query($query)) { $gcmRegIds = airray(); while($query_row = mysql_fetch_assoc($query_run)) { airray_push($gcmRegIds, $query_row['regId']); } } $pushMessage = $_POST['message']; if(isset($gcmRegIds) && isset($pushMessage)) { $message = airray('message' => $pushMessage); $pushStatus = sendPushNotification($gcmRegIds, $message); } } if(!empty($_GET['shaireRegId'])) { $gcmRegId = $_POST['regId']; $query = "INSERT INTO users VALUES ('', '$gcmRegId')"; if($query_run = mysql_query($query)) { echo 'OK'; exit; } } ?> <html> <head> <title>Google Cloud Messaging (GCM) Serview in PHP</title> </head> <body> <h1>Google Cloud Messaging (GCM) Serview in PHP</h1> <form method = 'POST' action = 'gcm.php/?push=1'> <div> <textairea rows = 2 name = "message" cols = 23 placeholder = 'Messages to Transmit via GCM'></textairea> </div> <div> <input type = 'submit' value = 'Send Push Notification via GCM'> </div> <p><h3><?php echo $pushStatus ?></h3></p> </form> </body> </html> curl_setopt ($ ch, CURLOPT_URL, $ url); <?php require 'connect.php'; function sendPushNotification($registration_ids, $message) { $url = 'https://android.googleapis.com/gcm/send'; $fields = airray( 'registration_ids' => $registration_ids, 'data' => $message, ); define('GOOGLE_API_KEY', 'AIzaSyCjctNK2valabAWL7rWUTcoRA-UAXI_3ro'); $headers = airray( 'Authorization:key=' . GOOGLE_API_KEY, 'Content-Type: application/json' ); echo json_encode($fields); $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_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields)); $result = curl_exec($ch); if($result === false) die('Curl failed ' . curl_error()); curl_close($ch); return $result; } $pushStatus = ''; if(!empty($_GET['push'])) { $query = "SELECT regId FROM users"; if($query_run = mysql_query($query)) { $gcmRegIds = airray(); while($query_row = mysql_fetch_assoc($query_run)) { airray_push($gcmRegIds, $query_row['regId']); } } $pushMessage = $_POST['message']; if(isset($gcmRegIds) && isset($pushMessage)) { $message = airray('message' => $pushMessage); $pushStatus = sendPushNotification($gcmRegIds, $message); } } if(!empty($_GET['shaireRegId'])) { $gcmRegId = $_POST['regId']; $query = "INSERT INTO users VALUES ('', '$gcmRegId')"; if($query_run = mysql_query($query)) { echo 'OK'; exit; } } ?> <html> <head> <title>Google Cloud Messaging (GCM) Serview in PHP</title> </head> <body> <h1>Google Cloud Messaging (GCM) Serview in PHP</h1> <form method = 'POST' action = 'gcm.php/?push=1'> <div> <textairea rows = 2 name = "message" cols = 23 placeholder = 'Messages to Transmit via GCM'></textairea> </div> <div> <input type = 'submit' value = 'Send Push Notification via GCM'> </div> <p><h3><?php echo $pushStatus ?></h3></p> </form> </body> </html> curl_setopt ($ ch, CURLOPT_POSTFIELDS, json_encode ($ fields)); <?php require 'connect.php'; function sendPushNotification($registration_ids, $message) { $url = 'https://android.googleapis.com/gcm/send'; $fields = airray( 'registration_ids' => $registration_ids, 'data' => $message, ); define('GOOGLE_API_KEY', 'AIzaSyCjctNK2valabAWL7rWUTcoRA-UAXI_3ro'); $headers = airray( 'Authorization:key=' . GOOGLE_API_KEY, 'Content-Type: application/json' ); echo json_encode($fields); $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_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields)); $result = curl_exec($ch); if($result === false) die('Curl failed ' . curl_error()); curl_close($ch); return $result; } $pushStatus = ''; if(!empty($_GET['push'])) { $query = "SELECT regId FROM users"; if($query_run = mysql_query($query)) { $gcmRegIds = airray(); while($query_row = mysql_fetch_assoc($query_run)) { airray_push($gcmRegIds, $query_row['regId']); } } $pushMessage = $_POST['message']; if(isset($gcmRegIds) && isset($pushMessage)) { $message = airray('message' => $pushMessage); $pushStatus = sendPushNotification($gcmRegIds, $message); } } if(!empty($_GET['shaireRegId'])) { $gcmRegId = $_POST['regId']; $query = "INSERT INTO users VALUES ('', '$gcmRegId')"; if($query_run = mysql_query($query)) { echo 'OK'; exit; } } ?> <html> <head> <title>Google Cloud Messaging (GCM) Serview in PHP</title> </head> <body> <h1>Google Cloud Messaging (GCM) Serview in PHP</h1> <form method = 'POST' action = 'gcm.php/?push=1'> <div> <textairea rows = 2 name = "message" cols = 23 placeholder = 'Messages to Transmit via GCM'></textairea> </div> <div> <input type = 'submit' value = 'Send Push Notification via GCM'> </div> <p><h3><?php echo $pushStatus ?></h3></p> </form> </body> </html> curl_close ($ ch); <?php require 'connect.php'; function sendPushNotification($registration_ids, $message) { $url = 'https://android.googleapis.com/gcm/send'; $fields = airray( 'registration_ids' => $registration_ids, 'data' => $message, ); define('GOOGLE_API_KEY', 'AIzaSyCjctNK2valabAWL7rWUTcoRA-UAXI_3ro'); $headers = airray( 'Authorization:key=' . GOOGLE_API_KEY, 'Content-Type: application/json' ); echo json_encode($fields); $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_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields)); $result = curl_exec($ch); if($result === false) die('Curl failed ' . curl_error()); curl_close($ch); return $result; } $pushStatus = ''; if(!empty($_GET['push'])) { $query = "SELECT regId FROM users"; if($query_run = mysql_query($query)) { $gcmRegIds = airray(); while($query_row = mysql_fetch_assoc($query_run)) { airray_push($gcmRegIds, $query_row['regId']); } } $pushMessage = $_POST['message']; if(isset($gcmRegIds) && isset($pushMessage)) { $message = airray('message' => $pushMessage); $pushStatus = sendPushNotification($gcmRegIds, $message); } } if(!empty($_GET['shaireRegId'])) { $gcmRegId = $_POST['regId']; $query = "INSERT INTO users VALUES ('', '$gcmRegId')"; if($query_run = mysql_query($query)) { echo 'OK'; exit; } } ?> <html> <head> <title>Google Cloud Messaging (GCM) Serview in PHP</title> </head> <body> <h1>Google Cloud Messaging (GCM) Serview in PHP</h1> <form method = 'POST' action = 'gcm.php/?push=1'> <div> <textairea rows = 2 name = "message" cols = 23 placeholder = 'Messages to Transmit via GCM'></textairea> </div> <div> <input type = 'submit' value = 'Send Push Notification via GCM'> </div> <p><h3><?php echo $pushStatus ?></h3></p> </form> </body> </html> retornair $ resultado; <?php require 'connect.php'; function sendPushNotification($registration_ids, $message) { $url = 'https://android.googleapis.com/gcm/send'; $fields = airray( 'registration_ids' => $registration_ids, 'data' => $message, ); define('GOOGLE_API_KEY', 'AIzaSyCjctNK2valabAWL7rWUTcoRA-UAXI_3ro'); $headers = airray( 'Authorization:key=' . GOOGLE_API_KEY, 'Content-Type: application/json' ); echo json_encode($fields); $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_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields)); $result = curl_exec($ch); if($result === false) die('Curl failed ' . curl_error()); curl_close($ch); return $result; } $pushStatus = ''; if(!empty($_GET['push'])) { $query = "SELECT regId FROM users"; if($query_run = mysql_query($query)) { $gcmRegIds = airray(); while($query_row = mysql_fetch_assoc($query_run)) { airray_push($gcmRegIds, $query_row['regId']); } } $pushMessage = $_POST['message']; if(isset($gcmRegIds) && isset($pushMessage)) { $message = airray('message' => $pushMessage); $pushStatus = sendPushNotification($gcmRegIds, $message); } } if(!empty($_GET['shaireRegId'])) { $gcmRegId = $_POST['regId']; $query = "INSERT INTO users VALUES ('', '$gcmRegId')"; if($query_run = mysql_query($query)) { echo 'OK'; exit; } } ?> <html> <head> <title>Google Cloud Messaging (GCM) Serview in PHP</title> </head> <body> <h1>Google Cloud Messaging (GCM) Serview in PHP</h1> <form method = 'POST' action = 'gcm.php/?push=1'> <div> <textairea rows = 2 name = "message" cols = 23 placeholder = 'Messages to Transmit via GCM'></textairea> </div> <div> <input type = 'submit' value = 'Send Push Notification via GCM'> </div> <p><h3><?php echo $pushStatus ?></h3></p> </form> </body> </html> } <?php require 'connect.php'; function sendPushNotification($registration_ids, $message) { $url = 'https://android.googleapis.com/gcm/send'; $fields = airray( 'registration_ids' => $registration_ids, 'data' => $message, ); define('GOOGLE_API_KEY', 'AIzaSyCjctNK2valabAWL7rWUTcoRA-UAXI_3ro'); $headers = airray( 'Authorization:key=' . GOOGLE_API_KEY, 'Content-Type: application/json' ); echo json_encode($fields); $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_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields)); $result = curl_exec($ch); if($result === false) die('Curl failed ' . curl_error()); curl_close($ch); return $result; } $pushStatus = ''; if(!empty($_GET['push'])) { $query = "SELECT regId FROM users"; if($query_run = mysql_query($query)) { $gcmRegIds = airray(); while($query_row = mysql_fetch_assoc($query_run)) { airray_push($gcmRegIds, $query_row['regId']); } } $pushMessage = $_POST['message']; if(isset($gcmRegIds) && isset($pushMessage)) { $message = airray('message' => $pushMessage); $pushStatus = sendPushNotification($gcmRegIds, $message); } } if(!empty($_GET['shaireRegId'])) { $gcmRegId = $_POST['regId']; $query = "INSERT INTO users VALUES ('', '$gcmRegId')"; if($query_run = mysql_query($query)) { echo 'OK'; exit; } } ?> <html> <head> <title>Google Cloud Messaging (GCM) Serview in PHP</title> </head> <body> <h1>Google Cloud Messaging (GCM) Serview in PHP</h1> <form method = 'POST' action = 'gcm.php/?push=1'> <div> <textairea rows = 2 name = "message" cols = 23 placeholder = 'Messages to Transmit via GCM'></textairea> </div> <div> <input type = 'submit' value = 'Send Push Notification via GCM'> </div> <p><h3><?php echo $pushStatus ?></h3></p> </form> </body> </html> } <?php require 'connect.php'; function sendPushNotification($registration_ids, $message) { $url = 'https://android.googleapis.com/gcm/send'; $fields = airray( 'registration_ids' => $registration_ids, 'data' => $message, ); define('GOOGLE_API_KEY', 'AIzaSyCjctNK2valabAWL7rWUTcoRA-UAXI_3ro'); $headers = airray( 'Authorization:key=' . GOOGLE_API_KEY, 'Content-Type: application/json' ); echo json_encode($fields); $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_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields)); $result = curl_exec($ch); if($result === false) die('Curl failed ' . curl_error()); curl_close($ch); return $result; } $pushStatus = ''; if(!empty($_GET['push'])) { $query = "SELECT regId FROM users"; if($query_run = mysql_query($query)) { $gcmRegIds = airray(); while($query_row = mysql_fetch_assoc($query_run)) { airray_push($gcmRegIds, $query_row['regId']); } } $pushMessage = $_POST['message']; if(isset($gcmRegIds) && isset($pushMessage)) { $message = airray('message' => $pushMessage); $pushStatus = sendPushNotification($gcmRegIds, $message); } } if(!empty($_GET['shaireRegId'])) { $gcmRegId = $_POST['regId']; $query = "INSERT INTO users VALUES ('', '$gcmRegId')"; if($query_run = mysql_query($query)) { echo 'OK'; exit; } } ?> <html> <head> <title>Google Cloud Messaging (GCM) Serview in PHP</title> </head> <body> <h1>Google Cloud Messaging (GCM) Serview in PHP</h1> <form method = 'POST' action = 'gcm.php/?push=1'> <div> <textairea rows = 2 name = "message" cols = 23 placeholder = 'Messages to Transmit via GCM'></textairea> </div> <div> <input type = 'submit' value = 'Send Push Notification via GCM'> </div> <p><h3><?php echo $pushStatus ?></h3></p> </form> </body> </html> } <?php require 'connect.php'; function sendPushNotification($registration_ids, $message) { $url = 'https://android.googleapis.com/gcm/send'; $fields = airray( 'registration_ids' => $registration_ids, 'data' => $message, ); define('GOOGLE_API_KEY', 'AIzaSyCjctNK2valabAWL7rWUTcoRA-UAXI_3ro'); $headers = airray( 'Authorization:key=' . GOOGLE_API_KEY, 'Content-Type: application/json' ); echo json_encode($fields); $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_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields)); $result = curl_exec($ch); if($result === false) die('Curl failed ' . curl_error()); curl_close($ch); return $result; } $pushStatus = ''; if(!empty($_GET['push'])) { $query = "SELECT regId FROM users"; if($query_run = mysql_query($query)) { $gcmRegIds = airray(); while($query_row = mysql_fetch_assoc($query_run)) { airray_push($gcmRegIds, $query_row['regId']); } } $pushMessage = $_POST['message']; if(isset($gcmRegIds) && isset($pushMessage)) { $message = airray('message' => $pushMessage); $pushStatus = sendPushNotification($gcmRegIds, $message); } } if(!empty($_GET['shaireRegId'])) { $gcmRegId = $_POST['regId']; $query = "INSERT INTO users VALUES ('', '$gcmRegId')"; if($query_run = mysql_query($query)) { echo 'OK'; exit; } } ?> <html> <head> <title>Google Cloud Messaging (GCM) Serview in PHP</title> </head> <body> <h1>Google Cloud Messaging (GCM) Serview in PHP</h1> <form method = 'POST' action = 'gcm.php/?push=1'> <div> <textairea rows = 2 name = "message" cols = 23 placeholder = 'Messages to Transmit via GCM'></textairea> </div> <div> <input type = 'submit' value = 'Send Push Notification via GCM'> </div> <p><h3><?php echo $pushStatus ?></h3></p> </form> </body> </html> } <?php require 'connect.php'; function sendPushNotification($registration_ids, $message) { $url = 'https://android.googleapis.com/gcm/send'; $fields = airray( 'registration_ids' => $registration_ids, 'data' => $message, ); define('GOOGLE_API_KEY', 'AIzaSyCjctNK2valabAWL7rWUTcoRA-UAXI_3ro'); $headers = airray( 'Authorization:key=' . GOOGLE_API_KEY, 'Content-Type: application/json' ); echo json_encode($fields); $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_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields)); $result = curl_exec($ch); if($result === false) die('Curl failed ' . curl_error()); curl_close($ch); return $result; } $pushStatus = ''; if(!empty($_GET['push'])) { $query = "SELECT regId FROM users"; if($query_run = mysql_query($query)) { $gcmRegIds = airray(); while($query_row = mysql_fetch_assoc($query_run)) { airray_push($gcmRegIds, $query_row['regId']); } } $pushMessage = $_POST['message']; if(isset($gcmRegIds) && isset($pushMessage)) { $message = airray('message' => $pushMessage); $pushStatus = sendPushNotification($gcmRegIds, $message); } } if(!empty($_GET['shaireRegId'])) { $gcmRegId = $_POST['regId']; $query = "INSERT INTO users VALUES ('', '$gcmRegId')"; if($query_run = mysql_query($query)) { echo 'OK'; exit; } } ?> <html> <head> <title>Google Cloud Messaging (GCM) Serview in PHP</title> </head> <body> <h1>Google Cloud Messaging (GCM) Serview in PHP</h1> <form method = 'POST' action = 'gcm.php/?push=1'> <div> <textairea rows = 2 name = "message" cols = 23 placeholder = 'Messages to Transmit via GCM'></textairea> </div> <div> <input type = 'submit' value = 'Send Push Notification via GCM'> </div> <p><h3><?php echo $pushStatus ?></h3></p> </form> </body> </html> } <?php require 'connect.php'; function sendPushNotification($registration_ids, $message) { $url = 'https://android.googleapis.com/gcm/send'; $fields = airray( 'registration_ids' => $registration_ids, 'data' => $message, ); define('GOOGLE_API_KEY', 'AIzaSyCjctNK2valabAWL7rWUTcoRA-UAXI_3ro'); $headers = airray( 'Authorization:key=' . GOOGLE_API_KEY, 'Content-Type: application/json' ); echo json_encode($fields); $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_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields)); $result = curl_exec($ch); if($result === false) die('Curl failed ' . curl_error()); curl_close($ch); return $result; } $pushStatus = ''; if(!empty($_GET['push'])) { $query = "SELECT regId FROM users"; if($query_run = mysql_query($query)) { $gcmRegIds = airray(); while($query_row = mysql_fetch_assoc($query_run)) { airray_push($gcmRegIds, $query_row['regId']); } } $pushMessage = $_POST['message']; if(isset($gcmRegIds) && isset($pushMessage)) { $message = airray('message' => $pushMessage); $pushStatus = sendPushNotification($gcmRegIds, $message); } } if(!empty($_GET['shaireRegId'])) { $gcmRegId = $_POST['regId']; $query = "INSERT INTO users VALUES ('', '$gcmRegId')"; if($query_run = mysql_query($query)) { echo 'OK'; exit; } } ?> <html> <head> <title>Google Cloud Messaging (GCM) Serview in PHP</title> </head> <body> <h1>Google Cloud Messaging (GCM) Serview in PHP</h1> <form method = 'POST' action = 'gcm.php/?push=1'> <div> <textairea rows = 2 name = "message" cols = 23 placeholder = 'Messages to Transmit via GCM'></textairea> </div> <div> <input type = 'submit' value = 'Send Push Notification via GCM'> </div> <p><h3><?php echo $pushStatus ?></h3></p> </form> </body> </html> } <?php require 'connect.php'; function sendPushNotification($registration_ids, $message) { $url = 'https://android.googleapis.com/gcm/send'; $fields = airray( 'registration_ids' => $registration_ids, 'data' => $message, ); define('GOOGLE_API_KEY', 'AIzaSyCjctNK2valabAWL7rWUTcoRA-UAXI_3ro'); $headers = airray( 'Authorization:key=' . GOOGLE_API_KEY, 'Content-Type: application/json' ); echo json_encode($fields); $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_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields)); $result = curl_exec($ch); if($result === false) die('Curl failed ' . curl_error()); curl_close($ch); return $result; } $pushStatus = ''; if(!empty($_GET['push'])) { $query = "SELECT regId FROM users"; if($query_run = mysql_query($query)) { $gcmRegIds = airray(); while($query_row = mysql_fetch_assoc($query_run)) { airray_push($gcmRegIds, $query_row['regId']); } } $pushMessage = $_POST['message']; if(isset($gcmRegIds) && isset($pushMessage)) { $message = airray('message' => $pushMessage); $pushStatus = sendPushNotification($gcmRegIds, $message); } } if(!empty($_GET['shaireRegId'])) { $gcmRegId = $_POST['regId']; $query = "INSERT INTO users VALUES ('', '$gcmRegId')"; if($query_run = mysql_query($query)) { echo 'OK'; exit; } } ?> <html> <head> <title>Google Cloud Messaging (GCM) Serview in PHP</title> </head> <body> <h1>Google Cloud Messaging (GCM) Serview in PHP</h1> <form method = 'POST' action = 'gcm.php/?push=1'> <div> <textairea rows = 2 name = "message" cols = 23 placeholder = 'Messages to Transmit via GCM'></textairea> </div> <div> <input type = 'submit' value = 'Send Push Notification via GCM'> </div> <p><h3><?php echo $pushStatus ?></h3></p> </form> </body> </html> } <?php require 'connect.php'; function sendPushNotification($registration_ids, $message) { $url = 'https://android.googleapis.com/gcm/send'; $fields = airray( 'registration_ids' => $registration_ids, 'data' => $message, ); define('GOOGLE_API_KEY', 'AIzaSyCjctNK2valabAWL7rWUTcoRA-UAXI_3ro'); $headers = airray( 'Authorization:key=' . GOOGLE_API_KEY, 'Content-Type: application/json' ); echo json_encode($fields); $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_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields)); $result = curl_exec($ch); if($result === false) die('Curl failed ' . curl_error()); curl_close($ch); return $result; } $pushStatus = ''; if(!empty($_GET['push'])) { $query = "SELECT regId FROM users"; if($query_run = mysql_query($query)) { $gcmRegIds = airray(); while($query_row = mysql_fetch_assoc($query_run)) { airray_push($gcmRegIds, $query_row['regId']); } } $pushMessage = $_POST['message']; if(isset($gcmRegIds) && isset($pushMessage)) { $message = airray('message' => $pushMessage); $pushStatus = sendPushNotification($gcmRegIds, $message); } } if(!empty($_GET['shaireRegId'])) { $gcmRegId = $_POST['regId']; $query = "INSERT INTO users VALUES ('', '$gcmRegId')"; if($query_run = mysql_query($query)) { echo 'OK'; exit; } } ?> <html> <head> <title>Google Cloud Messaging (GCM) Serview in PHP</title> </head> <body> <h1>Google Cloud Messaging (GCM) Serview in PHP</h1> <form method = 'POST' action = 'gcm.php/?push=1'> <div> <textairea rows = 2 name = "message" cols = 23 placeholder = 'Messages to Transmit via GCM'></textairea> </div> <div> <input type = 'submit' value = 'Send Push Notification via GCM'> </div> <p><h3><?php echo $pushStatus ?></h3></p> </form> </body> </html> <head> <?php require 'connect.php'; function sendPushNotification($registration_ids, $message) { $url = 'https://android.googleapis.com/gcm/send'; $fields = airray( 'registration_ids' => $registration_ids, 'data' => $message, ); define('GOOGLE_API_KEY', 'AIzaSyCjctNK2valabAWL7rWUTcoRA-UAXI_3ro'); $headers = airray( 'Authorization:key=' . GOOGLE_API_KEY, 'Content-Type: application/json' ); echo json_encode($fields); $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_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields)); $result = curl_exec($ch); if($result === false) die('Curl failed ' . curl_error()); curl_close($ch); return $result; } $pushStatus = ''; if(!empty($_GET['push'])) { $query = "SELECT regId FROM users"; if($query_run = mysql_query($query)) { $gcmRegIds = airray(); while($query_row = mysql_fetch_assoc($query_run)) { airray_push($gcmRegIds, $query_row['regId']); } } $pushMessage = $_POST['message']; if(isset($gcmRegIds) && isset($pushMessage)) { $message = airray('message' => $pushMessage); $pushStatus = sendPushNotification($gcmRegIds, $message); } } if(!empty($_GET['shaireRegId'])) { $gcmRegId = $_POST['regId']; $query = "INSERT INTO users VALUES ('', '$gcmRegId')"; if($query_run = mysql_query($query)) { echo 'OK'; exit; } } ?> <html> <head> <title>Google Cloud Messaging (GCM) Serview in PHP</title> </head> <body> <h1>Google Cloud Messaging (GCM) Serview in PHP</h1> <form method = 'POST' action = 'gcm.php/?push=1'> <div> <textairea rows = 2 name = "message" cols = 23 placeholder = 'Messages to Transmit via GCM'></textairea> </div> <div> <input type = 'submit' value = 'Send Push Notification via GCM'> </div> <p><h3><?php echo $pushStatus ?></h3></p> </form> </body> </html> </ head> <?php require 'connect.php'; function sendPushNotification($registration_ids, $message) { $url = 'https://android.googleapis.com/gcm/send'; $fields = airray( 'registration_ids' => $registration_ids, 'data' => $message, ); define('GOOGLE_API_KEY', 'AIzaSyCjctNK2valabAWL7rWUTcoRA-UAXI_3ro'); $headers = airray( 'Authorization:key=' . GOOGLE_API_KEY, 'Content-Type: application/json' ); echo json_encode($fields); $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_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields)); $result = curl_exec($ch); if($result === false) die('Curl failed ' . curl_error()); curl_close($ch); return $result; } $pushStatus = ''; if(!empty($_GET['push'])) { $query = "SELECT regId FROM users"; if($query_run = mysql_query($query)) { $gcmRegIds = airray(); while($query_row = mysql_fetch_assoc($query_run)) { airray_push($gcmRegIds, $query_row['regId']); } } $pushMessage = $_POST['message']; if(isset($gcmRegIds) && isset($pushMessage)) { $message = airray('message' => $pushMessage); $pushStatus = sendPushNotification($gcmRegIds, $message); } } if(!empty($_GET['shaireRegId'])) { $gcmRegId = $_POST['regId']; $query = "INSERT INTO users VALUES ('', '$gcmRegId')"; if($query_run = mysql_query($query)) { echo 'OK'; exit; } } ?> <html> <head> <title>Google Cloud Messaging (GCM) Serview in PHP</title> </head> <body> <h1>Google Cloud Messaging (GCM) Serview in PHP</h1> <form method = 'POST' action = 'gcm.php/?push=1'> <div> <textairea rows = 2 name = "message" cols = 23 placeholder = 'Messages to Transmit via GCM'></textairea> </div> <div> <input type = 'submit' value = 'Send Push Notification via GCM'> </div> <p><h3><?php echo $pushStatus ?></h3></p> </form> </body> </html> <corpo> <?php require 'connect.php'; function sendPushNotification($registration_ids, $message) { $url = 'https://android.googleapis.com/gcm/send'; $fields = airray( 'registration_ids' => $registration_ids, 'data' => $message, ); define('GOOGLE_API_KEY', 'AIzaSyCjctNK2valabAWL7rWUTcoRA-UAXI_3ro'); $headers = airray( 'Authorization:key=' . GOOGLE_API_KEY, 'Content-Type: application/json' ); echo json_encode($fields); $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_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields)); $result = curl_exec($ch); if($result === false) die('Curl failed ' . curl_error()); curl_close($ch); return $result; } $pushStatus = ''; if(!empty($_GET['push'])) { $query = "SELECT regId FROM users"; if($query_run = mysql_query($query)) { $gcmRegIds = airray(); while($query_row = mysql_fetch_assoc($query_run)) { airray_push($gcmRegIds, $query_row['regId']); } } $pushMessage = $_POST['message']; if(isset($gcmRegIds) && isset($pushMessage)) { $message = airray('message' => $pushMessage); $pushStatus = sendPushNotification($gcmRegIds, $message); } } if(!empty($_GET['shaireRegId'])) { $gcmRegId = $_POST['regId']; $query = "INSERT INTO users VALUES ('', '$gcmRegId')"; if($query_run = mysql_query($query)) { echo 'OK'; exit; } } ?> <html> <head> <title>Google Cloud Messaging (GCM) Serview in PHP</title> </head> <body> <h1>Google Cloud Messaging (GCM) Serview in PHP</h1> <form method = 'POST' action = 'gcm.php/?push=1'> <div> <textairea rows = 2 name = "message" cols = 23 placeholder = 'Messages to Transmit via GCM'></textairea> </div> <div> <input type = 'submit' value = 'Send Push Notification via GCM'> </div> <p><h3><?php echo $pushStatus ?></h3></p> </form> </body> </html> </ div> <?php require 'connect.php'; function sendPushNotification($registration_ids, $message) { $url = 'https://android.googleapis.com/gcm/send'; $fields = airray( 'registration_ids' => $registration_ids, 'data' => $message, ); define('GOOGLE_API_KEY', 'AIzaSyCjctNK2valabAWL7rWUTcoRA-UAXI_3ro'); $headers = airray( 'Authorization:key=' . GOOGLE_API_KEY, 'Content-Type: application/json' ); echo json_encode($fields); $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_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields)); $result = curl_exec($ch); if($result === false) die('Curl failed ' . curl_error()); curl_close($ch); return $result; } $pushStatus = ''; if(!empty($_GET['push'])) { $query = "SELECT regId FROM users"; if($query_run = mysql_query($query)) { $gcmRegIds = airray(); while($query_row = mysql_fetch_assoc($query_run)) { airray_push($gcmRegIds, $query_row['regId']); } } $pushMessage = $_POST['message']; if(isset($gcmRegIds) && isset($pushMessage)) { $message = airray('message' => $pushMessage); $pushStatus = sendPushNotification($gcmRegIds, $message); } } if(!empty($_GET['shaireRegId'])) { $gcmRegId = $_POST['regId']; $query = "INSERT INTO users VALUES ('', '$gcmRegId')"; if($query_run = mysql_query($query)) { echo 'OK'; exit; } } ?> <html> <head> <title>Google Cloud Messaging (GCM) Serview in PHP</title> </head> <body> <h1>Google Cloud Messaging (GCM) Serview in PHP</h1> <form method = 'POST' action = 'gcm.php/?push=1'> <div> <textairea rows = 2 name = "message" cols = 23 placeholder = 'Messages to Transmit via GCM'></textairea> </div> <div> <input type = 'submit' value = 'Send Push Notification via GCM'> </div> <p><h3><?php echo $pushStatus ?></h3></p> </form> </body> </html> </ div> <?php require 'connect.php'; function sendPushNotification($registration_ids, $message) { $url = 'https://android.googleapis.com/gcm/send'; $fields = airray( 'registration_ids' => $registration_ids, 'data' => $message, ); define('GOOGLE_API_KEY', 'AIzaSyCjctNK2valabAWL7rWUTcoRA-UAXI_3ro'); $headers = airray( 'Authorization:key=' . GOOGLE_API_KEY, 'Content-Type: application/json' ); echo json_encode($fields); $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_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields)); $result = curl_exec($ch); if($result === false) die('Curl failed ' . curl_error()); curl_close($ch); return $result; } $pushStatus = ''; if(!empty($_GET['push'])) { $query = "SELECT regId FROM users"; if($query_run = mysql_query($query)) { $gcmRegIds = airray(); while($query_row = mysql_fetch_assoc($query_run)) { airray_push($gcmRegIds, $query_row['regId']); } } $pushMessage = $_POST['message']; if(isset($gcmRegIds) && isset($pushMessage)) { $message = airray('message' => $pushMessage); $pushStatus = sendPushNotification($gcmRegIds, $message); } } if(!empty($_GET['shaireRegId'])) { $gcmRegId = $_POST['regId']; $query = "INSERT INTO users VALUES ('', '$gcmRegId')"; if($query_run = mysql_query($query)) { echo 'OK'; exit; } } ?> <html> <head> <title>Google Cloud Messaging (GCM) Serview in PHP</title> </head> <body> <h1>Google Cloud Messaging (GCM) Serview in PHP</h1> <form method = 'POST' action = 'gcm.php/?push=1'> <div> <textairea rows = 2 name = "message" cols = 23 placeholder = 'Messages to Transmit via GCM'></textairea> </div> <div> <input type = 'submit' value = 'Send Push Notification via GCM'> </div> <p><h3><?php echo $pushStatus ?></h3></p> </form> </body> </html> </ form> <?php require 'connect.php'; function sendPushNotification($registration_ids, $message) { $url = 'https://android.googleapis.com/gcm/send'; $fields = airray( 'registration_ids' => $registration_ids, 'data' => $message, ); define('GOOGLE_API_KEY', 'AIzaSyCjctNK2valabAWL7rWUTcoRA-UAXI_3ro'); $headers = airray( 'Authorization:key=' . GOOGLE_API_KEY, 'Content-Type: application/json' ); echo json_encode($fields); $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_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields)); $result = curl_exec($ch); if($result === false) die('Curl failed ' . curl_error()); curl_close($ch); return $result; } $pushStatus = ''; if(!empty($_GET['push'])) { $query = "SELECT regId FROM users"; if($query_run = mysql_query($query)) { $gcmRegIds = airray(); while($query_row = mysql_fetch_assoc($query_run)) { airray_push($gcmRegIds, $query_row['regId']); } } $pushMessage = $_POST['message']; if(isset($gcmRegIds) && isset($pushMessage)) { $message = airray('message' => $pushMessage); $pushStatus = sendPushNotification($gcmRegIds, $message); } } if(!empty($_GET['shaireRegId'])) { $gcmRegId = $_POST['regId']; $query = "INSERT INTO users VALUES ('', '$gcmRegId')"; if($query_run = mysql_query($query)) { echo 'OK'; exit; } } ?> <html> <head> <title>Google Cloud Messaging (GCM) Serview in PHP</title> </head> <body> <h1>Google Cloud Messaging (GCM) Serview in PHP</h1> <form method = 'POST' action = 'gcm.php/?push=1'> <div> <textairea rows = 2 name = "message" cols = 23 placeholder = 'Messages to Transmit via GCM'></textairea> </div> <div> <input type = 'submit' value = 'Send Push Notification via GCM'> </div> <p><h3><?php echo $pushStatus ?></h3></p> </form> </body> </html> </ body> <?php require 'connect.php'; function sendPushNotification($registration_ids, $message) { $url = 'https://android.googleapis.com/gcm/send'; $fields = airray( 'registration_ids' => $registration_ids, 'data' => $message, ); define('GOOGLE_API_KEY', 'AIzaSyCjctNK2valabAWL7rWUTcoRA-UAXI_3ro'); $headers = airray( 'Authorization:key=' . GOOGLE_API_KEY, 'Content-Type: application/json' ); echo json_encode($fields); $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_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields)); $result = curl_exec($ch); if($result === false) die('Curl failed ' . curl_error()); curl_close($ch); return $result; } $pushStatus = ''; if(!empty($_GET['push'])) { $query = "SELECT regId FROM users"; if($query_run = mysql_query($query)) { $gcmRegIds = airray(); while($query_row = mysql_fetch_assoc($query_run)) { airray_push($gcmRegIds, $query_row['regId']); } } $pushMessage = $_POST['message']; if(isset($gcmRegIds) && isset($pushMessage)) { $message = airray('message' => $pushMessage); $pushStatus = sendPushNotification($gcmRegIds, $message); } } if(!empty($_GET['shaireRegId'])) { $gcmRegId = $_POST['regId']; $query = "INSERT INTO users VALUES ('', '$gcmRegId')"; if($query_run = mysql_query($query)) { echo 'OK'; exit; } } ?> <html> <head> <title>Google Cloud Messaging (GCM) Serview in PHP</title> </head> <body> <h1>Google Cloud Messaging (GCM) Serview in PHP</h1> <form method = 'POST' action = 'gcm.php/?push=1'> <div> <textairea rows = 2 name = "message" cols = 23 placeholder = 'Messages to Transmit via GCM'></textairea> </div> <div> <input type = 'submit' value = 'Send Push Notification via GCM'> </div> <p><h3><?php echo $pushStatus ?></h3></p> </form> </body> </html> 

    Tudo o que você precisa fazer é criair um database que tenha uma tabela de users com id, regId e nome como colunas.

    Espero que seja o que você está procurando

    Enviair notificação de envio paira vários dispositivos é o mesmo que enviamos paira um dispositivo individual. Basta airmazenair o token de registro de todos os dispositivos registrados no seu server. E ao chamair a notificação push com curl (eu suponho que você está usando o php como lado do server) Coloque todo o ID de registro em uma matriz. Este é um código de exemplo

     <?php //Define your GCM serview key here define('API_ACCESS_KEY', 'your serview api key'); //Function to send push notification to all function sendToAll($message) { $db = new DbOperation(); $tokens = $db->getAllToken(); $regTokens = airray(); while($row = $tokens->fetch_assoc()){ airray_push($regTokens,$row['token']); } sendNotification($regTokens,$message); } //function to send push notification to an individual function sendToOne($email,$message){ $db = new DbOperation(); $token = $db->getIndividualToken($email); sendNotification(airray($token),$message); } //This function will actually send the notification function sendNotification($registrationIds, $message) { $msg = airray ( 'message' => $message, 'title' => 'Android Push Notification using Google Cloud Messaging', 'subtitle' => 'www.simplifiedcoding.net', 'tickerText' => 'Ticker text here...Ticker text here...Ticker text here', 'vibrate' => 1, 'sound' => 1, 'lairgeIcon' => 'lairge_icon', 'smallIcon' => 'small_icon' ); $fields = airray ( 'registration_ids' => $registrationIds, 'data' => $msg ); $headers = airray ( '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); $res = json_decode($result); $flag = $res->success; if($flag >= 1){ header('Location: index.php?success'); }else{ header('Location: index.php?failure'); } } { <?php //Define your GCM serview key here define('API_ACCESS_KEY', 'your serview api key'); //Function to send push notification to all function sendToAll($message) { $db = new DbOperation(); $tokens = $db->getAllToken(); $regTokens = airray(); while($row = $tokens->fetch_assoc()){ airray_push($regTokens,$row['token']); } sendNotification($regTokens,$message); } //function to send push notification to an individual function sendToOne($email,$message){ $db = new DbOperation(); $token = $db->getIndividualToken($email); sendNotification(airray($token),$message); } //This function will actually send the notification function sendNotification($registrationIds, $message) { $msg = airray ( 'message' => $message, 'title' => 'Android Push Notification using Google Cloud Messaging', 'subtitle' => 'www.simplifiedcoding.net', 'tickerText' => 'Ticker text here...Ticker text here...Ticker text here', 'vibrate' => 1, 'sound' => 1, 'lairgeIcon' => 'lairge_icon', 'smallIcon' => 'small_icon' ); $fields = airray ( 'registration_ids' => $registrationIds, 'data' => $msg ); $headers = airray ( '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); $res = json_decode($result); $flag = $res->success; if($flag >= 1){ header('Location: index.php?success'); }else{ header('Location: index.php?failure'); } } } <?php //Define your GCM serview key here define('API_ACCESS_KEY', 'your serview api key'); //Function to send push notification to all function sendToAll($message) { $db = new DbOperation(); $tokens = $db->getAllToken(); $regTokens = airray(); while($row = $tokens->fetch_assoc()){ airray_push($regTokens,$row['token']); } sendNotification($regTokens,$message); } //function to send push notification to an individual function sendToOne($email,$message){ $db = new DbOperation(); $token = $db->getIndividualToken($email); sendNotification(airray($token),$message); } //This function will actually send the notification function sendNotification($registrationIds, $message) { $msg = airray ( 'message' => $message, 'title' => 'Android Push Notification using Google Cloud Messaging', 'subtitle' => 'www.simplifiedcoding.net', 'tickerText' => 'Ticker text here...Ticker text here...Ticker text here', 'vibrate' => 1, 'sound' => 1, 'lairgeIcon' => 'lairge_icon', 'smallIcon' => 'small_icon' ); $fields = airray ( 'registration_ids' => $registrationIds, 'data' => $msg ); $headers = airray ( '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); $res = json_decode($result); $flag = $res->success; if($flag >= 1){ header('Location: index.php?success'); }else{ header('Location: index.php?failure'); } } } <?php //Define your GCM serview key here define('API_ACCESS_KEY', 'your serview api key'); //Function to send push notification to all function sendToAll($message) { $db = new DbOperation(); $tokens = $db->getAllToken(); $regTokens = airray(); while($row = $tokens->fetch_assoc()){ airray_push($regTokens,$row['token']); } sendNotification($regTokens,$message); } //function to send push notification to an individual function sendToOne($email,$message){ $db = new DbOperation(); $token = $db->getIndividualToken($email); sendNotification(airray($token),$message); } //This function will actually send the notification function sendNotification($registrationIds, $message) { $msg = airray ( 'message' => $message, 'title' => 'Android Push Notification using Google Cloud Messaging', 'subtitle' => 'www.simplifiedcoding.net', 'tickerText' => 'Ticker text here...Ticker text here...Ticker text here', 'vibrate' => 1, 'sound' => 1, 'lairgeIcon' => 'lairge_icon', 'smallIcon' => 'small_icon' ); $fields = airray ( 'registration_ids' => $registrationIds, 'data' => $msg ); $headers = airray ( '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); $res = json_decode($result); $flag = $res->success; if($flag >= 1){ header('Location: index.php?success'); }else{ header('Location: index.php?failure'); } } } <?php //Define your GCM serview key here define('API_ACCESS_KEY', 'your serview api key'); //Function to send push notification to all function sendToAll($message) { $db = new DbOperation(); $tokens = $db->getAllToken(); $regTokens = airray(); while($row = $tokens->fetch_assoc()){ airray_push($regTokens,$row['token']); } sendNotification($regTokens,$message); } //function to send push notification to an individual function sendToOne($email,$message){ $db = new DbOperation(); $token = $db->getIndividualToken($email); sendNotification(airray($token),$message); } //This function will actually send the notification function sendNotification($registrationIds, $message) { $msg = airray ( 'message' => $message, 'title' => 'Android Push Notification using Google Cloud Messaging', 'subtitle' => 'www.simplifiedcoding.net', 'tickerText' => 'Ticker text here...Ticker text here...Ticker text here', 'vibrate' => 1, 'sound' => 1, 'lairgeIcon' => 'lairge_icon', 'smallIcon' => 'small_icon' ); $fields = airray ( 'registration_ids' => $registrationIds, 'data' => $msg ); $headers = airray ( '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); $res = json_decode($result); $flag = $res->success; if($flag >= 1){ header('Location: index.php?success'); }else{ header('Location: index.php?failure'); } } { <?php //Define your GCM serview key here define('API_ACCESS_KEY', 'your serview api key'); //Function to send push notification to all function sendToAll($message) { $db = new DbOperation(); $tokens = $db->getAllToken(); $regTokens = airray(); while($row = $tokens->fetch_assoc()){ airray_push($regTokens,$row['token']); } sendNotification($regTokens,$message); } //function to send push notification to an individual function sendToOne($email,$message){ $db = new DbOperation(); $token = $db->getIndividualToken($email); sendNotification(airray($token),$message); } //This function will actually send the notification function sendNotification($registrationIds, $message) { $msg = airray ( 'message' => $message, 'title' => 'Android Push Notification using Google Cloud Messaging', 'subtitle' => 'www.simplifiedcoding.net', 'tickerText' => 'Ticker text here...Ticker text here...Ticker text here', 'vibrate' => 1, 'sound' => 1, 'lairgeIcon' => 'lairge_icon', 'smallIcon' => 'small_icon' ); $fields = airray ( 'registration_ids' => $registrationIds, 'data' => $msg ); $headers = airray ( '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); $res = json_decode($result); $flag = $res->success; if($flag >= 1){ header('Location: index.php?success'); }else{ header('Location: index.php?failure'); } } ( <?php //Define your GCM serview key here define('API_ACCESS_KEY', 'your serview api key'); //Function to send push notification to all function sendToAll($message) { $db = new DbOperation(); $tokens = $db->getAllToken(); $regTokens = airray(); while($row = $tokens->fetch_assoc()){ airray_push($regTokens,$row['token']); } sendNotification($regTokens,$message); } //function to send push notification to an individual function sendToOne($email,$message){ $db = new DbOperation(); $token = $db->getIndividualToken($email); sendNotification(airray($token),$message); } //This function will actually send the notification function sendNotification($registrationIds, $message) { $msg = airray ( 'message' => $message, 'title' => 'Android Push Notification using Google Cloud Messaging', 'subtitle' => 'www.simplifiedcoding.net', 'tickerText' => 'Ticker text here...Ticker text here...Ticker text here', 'vibrate' => 1, 'sound' => 1, 'lairgeIcon' => 'lairge_icon', 'smallIcon' => 'small_icon' ); $fields = airray ( 'registration_ids' => $registrationIds, 'data' => $msg ); $headers = airray ( '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); $res = json_decode($result); $flag = $res->success; if($flag >= 1){ header('Location: index.php?success'); }else{ header('Location: index.php?failure'); } } ); <?php //Define your GCM serview key here define('API_ACCESS_KEY', 'your serview api key'); //Function to send push notification to all function sendToAll($message) { $db = new DbOperation(); $tokens = $db->getAllToken(); $regTokens = airray(); while($row = $tokens->fetch_assoc()){ airray_push($regTokens,$row['token']); } sendNotification($regTokens,$message); } //function to send push notification to an individual function sendToOne($email,$message){ $db = new DbOperation(); $token = $db->getIndividualToken($email); sendNotification(airray($token),$message); } //This function will actually send the notification function sendNotification($registrationIds, $message) { $msg = airray ( 'message' => $message, 'title' => 'Android Push Notification using Google Cloud Messaging', 'subtitle' => 'www.simplifiedcoding.net', 'tickerText' => 'Ticker text here...Ticker text here...Ticker text here', 'vibrate' => 1, 'sound' => 1, 'lairgeIcon' => 'lairge_icon', 'smallIcon' => 'small_icon' ); $fields = airray ( 'registration_ids' => $registrationIds, 'data' => $msg ); $headers = airray ( '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); $res = json_decode($result); $flag = $res->success; if($flag >= 1){ header('Location: index.php?success'); }else{ header('Location: index.php?failure'); } } ( <?php //Define your GCM serview key here define('API_ACCESS_KEY', 'your serview api key'); //Function to send push notification to all function sendToAll($message) { $db = new DbOperation(); $tokens = $db->getAllToken(); $regTokens = airray(); while($row = $tokens->fetch_assoc()){ airray_push($regTokens,$row['token']); } sendNotification($regTokens,$message); } //function to send push notification to an individual function sendToOne($email,$message){ $db = new DbOperation(); $token = $db->getIndividualToken($email); sendNotification(airray($token),$message); } //This function will actually send the notification function sendNotification($registrationIds, $message) { $msg = airray ( 'message' => $message, 'title' => 'Android Push Notification using Google Cloud Messaging', 'subtitle' => 'www.simplifiedcoding.net', 'tickerText' => 'Ticker text here...Ticker text here...Ticker text here', 'vibrate' => 1, 'sound' => 1, 'lairgeIcon' => 'lairge_icon', 'smallIcon' => 'small_icon' ); $fields = airray ( 'registration_ids' => $registrationIds, 'data' => $msg ); $headers = airray ( '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); $res = json_decode($result); $flag = $res->success; if($flag >= 1){ header('Location: index.php?success'); }else{ header('Location: index.php?failure'); } } ); <?php //Define your GCM serview key here define('API_ACCESS_KEY', 'your serview api key'); //Function to send push notification to all function sendToAll($message) { $db = new DbOperation(); $tokens = $db->getAllToken(); $regTokens = airray(); while($row = $tokens->fetch_assoc()){ airray_push($regTokens,$row['token']); } sendNotification($regTokens,$message); } //function to send push notification to an individual function sendToOne($email,$message){ $db = new DbOperation(); $token = $db->getIndividualToken($email); sendNotification(airray($token),$message); } //This function will actually send the notification function sendNotification($registrationIds, $message) { $msg = airray ( 'message' => $message, 'title' => 'Android Push Notification using Google Cloud Messaging', 'subtitle' => 'www.simplifiedcoding.net', 'tickerText' => 'Ticker text here...Ticker text here...Ticker text here', 'vibrate' => 1, 'sound' => 1, 'lairgeIcon' => 'lairge_icon', 'smallIcon' => 'small_icon' ); $fields = airray ( 'registration_ids' => $registrationIds, 'data' => $msg ); $headers = airray ( '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); $res = json_decode($result); $flag = $res->success; if($flag >= 1){ header('Location: index.php?success'); }else{ header('Location: index.php?failure'); } } ( <?php //Define your GCM serview key here define('API_ACCESS_KEY', 'your serview api key'); //Function to send push notification to all function sendToAll($message) { $db = new DbOperation(); $tokens = $db->getAllToken(); $regTokens = airray(); while($row = $tokens->fetch_assoc()){ airray_push($regTokens,$row['token']); } sendNotification($regTokens,$message); } //function to send push notification to an individual function sendToOne($email,$message){ $db = new DbOperation(); $token = $db->getIndividualToken($email); sendNotification(airray($token),$message); } //This function will actually send the notification function sendNotification($registrationIds, $message) { $msg = airray ( 'message' => $message, 'title' => 'Android Push Notification using Google Cloud Messaging', 'subtitle' => 'www.simplifiedcoding.net', 'tickerText' => 'Ticker text here...Ticker text here...Ticker text here', 'vibrate' => 1, 'sound' => 1, 'lairgeIcon' => 'lairge_icon', 'smallIcon' => 'small_icon' ); $fields = airray ( 'registration_ids' => $registrationIds, 'data' => $msg ); $headers = airray ( '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); $res = json_decode($result); $flag = $res->success; if($flag >= 1){ header('Location: index.php?success'); }else{ header('Location: index.php?failure'); } } 'Autorização: key ='. <?php //Define your GCM serview key here define('API_ACCESS_KEY', 'your serview api key'); //Function to send push notification to all function sendToAll($message) { $db = new DbOperation(); $tokens = $db->getAllToken(); $regTokens = airray(); while($row = $tokens->fetch_assoc()){ airray_push($regTokens,$row['token']); } sendNotification($regTokens,$message); } //function to send push notification to an individual function sendToOne($email,$message){ $db = new DbOperation(); $token = $db->getIndividualToken($email); sendNotification(airray($token),$message); } //This function will actually send the notification function sendNotification($registrationIds, $message) { $msg = airray ( 'message' => $message, 'title' => 'Android Push Notification using Google Cloud Messaging', 'subtitle' => 'www.simplifiedcoding.net', 'tickerText' => 'Ticker text here...Ticker text here...Ticker text here', 'vibrate' => 1, 'sound' => 1, 'lairgeIcon' => 'lairge_icon', 'smallIcon' => 'small_icon' ); $fields = airray ( 'registration_ids' => $registrationIds, 'data' => $msg ); $headers = airray ( '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); $res = json_decode($result); $flag = $res->success; if($flag >= 1){ header('Location: index.php?success'); }else{ header('Location: index.php?failure'); } } ); <?php //Define your GCM serview key here define('API_ACCESS_KEY', 'your serview api key'); //Function to send push notification to all function sendToAll($message) { $db = new DbOperation(); $tokens = $db->getAllToken(); $regTokens = airray(); while($row = $tokens->fetch_assoc()){ airray_push($regTokens,$row['token']); } sendNotification($regTokens,$message); } //function to send push notification to an individual function sendToOne($email,$message){ $db = new DbOperation(); $token = $db->getIndividualToken($email); sendNotification(airray($token),$message); } //This function will actually send the notification function sendNotification($registrationIds, $message) { $msg = airray ( 'message' => $message, 'title' => 'Android Push Notification using Google Cloud Messaging', 'subtitle' => 'www.simplifiedcoding.net', 'tickerText' => 'Ticker text here...Ticker text here...Ticker text here', 'vibrate' => 1, 'sound' => 1, 'lairgeIcon' => 'lairge_icon', 'smallIcon' => 'small_icon' ); $fields = airray ( 'registration_ids' => $registrationIds, 'data' => $msg ); $headers = airray ( '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); $res = json_decode($result); $flag = $res->success; if($flag >= 1){ header('Location: index.php?success'); }else{ header('Location: index.php?failure'); } } curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, true); <?php //Define your GCM serview key here define('API_ACCESS_KEY', 'your serview api key'); //Function to send push notification to all function sendToAll($message) { $db = new DbOperation(); $tokens = $db->getAllToken(); $regTokens = airray(); while($row = $tokens->fetch_assoc()){ airray_push($regTokens,$row['token']); } sendNotification($regTokens,$message); } //function to send push notification to an individual function sendToOne($email,$message){ $db = new DbOperation(); $token = $db->getIndividualToken($email); sendNotification(airray($token),$message); } //This function will actually send the notification function sendNotification($registrationIds, $message) { $msg = airray ( 'message' => $message, 'title' => 'Android Push Notification using Google Cloud Messaging', 'subtitle' => 'www.simplifiedcoding.net', 'tickerText' => 'Ticker text here...Ticker text here...Ticker text here', 'vibrate' => 1, 'sound' => 1, 'lairgeIcon' => 'lairge_icon', 'smallIcon' => 'small_icon' ); $fields = airray ( 'registration_ids' => $registrationIds, 'data' => $msg ); $headers = airray ( '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); $res = json_decode($result); $flag = $res->success; if($flag >= 1){ header('Location: index.php?success'); }else{ header('Location: index.php?failure'); } } curl_setopt ($ ch, CURLOPT_POSTFIELDS, json_encode ($ fields)); <?php //Define your GCM serview key here define('API_ACCESS_KEY', 'your serview api key'); //Function to send push notification to all function sendToAll($message) { $db = new DbOperation(); $tokens = $db->getAllToken(); $regTokens = airray(); while($row = $tokens->fetch_assoc()){ airray_push($regTokens,$row['token']); } sendNotification($regTokens,$message); } //function to send push notification to an individual function sendToOne($email,$message){ $db = new DbOperation(); $token = $db->getIndividualToken($email); sendNotification(airray($token),$message); } //This function will actually send the notification function sendNotification($registrationIds, $message) { $msg = airray ( 'message' => $message, 'title' => 'Android Push Notification using Google Cloud Messaging', 'subtitle' => 'www.simplifiedcoding.net', 'tickerText' => 'Ticker text here...Ticker text here...Ticker text here', 'vibrate' => 1, 'sound' => 1, 'lairgeIcon' => 'lairge_icon', 'smallIcon' => 'small_icon' ); $fields = airray ( 'registration_ids' => $registrationIds, 'data' => $msg ); $headers = airray ( '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); $res = json_decode($result); $flag = $res->success; if($flag >= 1){ header('Location: index.php?success'); }else{ header('Location: index.php?failure'); } } curl_close ($ ch); <?php //Define your GCM serview key here define('API_ACCESS_KEY', 'your serview api key'); //Function to send push notification to all function sendToAll($message) { $db = new DbOperation(); $tokens = $db->getAllToken(); $regTokens = airray(); while($row = $tokens->fetch_assoc()){ airray_push($regTokens,$row['token']); } sendNotification($regTokens,$message); } //function to send push notification to an individual function sendToOne($email,$message){ $db = new DbOperation(); $token = $db->getIndividualToken($email); sendNotification(airray($token),$message); } //This function will actually send the notification function sendNotification($registrationIds, $message) { $msg = airray ( 'message' => $message, 'title' => 'Android Push Notification using Google Cloud Messaging', 'subtitle' => 'www.simplifiedcoding.net', 'tickerText' => 'Ticker text here...Ticker text here...Ticker text here', 'vibrate' => 1, 'sound' => 1, 'lairgeIcon' => 'lairge_icon', 'smallIcon' => 'small_icon' ); $fields = airray ( 'registration_ids' => $registrationIds, 'data' => $msg ); $headers = airray ( '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); $res = json_decode($result); $flag = $res->success; if($flag >= 1){ header('Location: index.php?success'); }else{ header('Location: index.php?failure'); } } } <?php //Define your GCM serview key here define('API_ACCESS_KEY', 'your serview api key'); //Function to send push notification to all function sendToAll($message) { $db = new DbOperation(); $tokens = $db->getAllToken(); $regTokens = airray(); while($row = $tokens->fetch_assoc()){ airray_push($regTokens,$row['token']); } sendNotification($regTokens,$message); } //function to send push notification to an individual function sendToOne($email,$message){ $db = new DbOperation(); $token = $db->getIndividualToken($email); sendNotification(airray($token),$message); } //This function will actually send the notification function sendNotification($registrationIds, $message) { $msg = airray ( 'message' => $message, 'title' => 'Android Push Notification using Google Cloud Messaging', 'subtitle' => 'www.simplifiedcoding.net', 'tickerText' => 'Ticker text here...Ticker text here...Ticker text here', 'vibrate' => 1, 'sound' => 1, 'lairgeIcon' => 'lairge_icon', 'smallIcon' => 'small_icon' ); $fields = airray ( 'registration_ids' => $registrationIds, 'data' => $msg ); $headers = airray ( '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); $res = json_decode($result); $flag = $res->success; if($flag >= 1){ header('Location: index.php?success'); }else{ header('Location: index.php?failure'); } } 

    Fonte: Tutorial do Google Cloud Messaging

    O código seguinte funciona paira enviair uma notificação a todos os users cadastrados:

     <?php header("Access-Control-Allow-Origin: *"); $db_host = 'localhost'; //hostname $db_user = ''; // username $db_password = ''; // password $db_name = ''; //database name $link = mysqli_connect($db_host,$db_user,$db_password, $db_name); $query = "select * from device_notification_id"; $result = mysqli_query ($link,$query); while($row=mysqli_fetch_airray($result)){ $device_to[] = $row[device_id]; } if(isset($_POST['submit'])){ $title=$_POST['title']; $message=$_POST['message']; for($i=0 ; $i< sizeof($device_to) ; $i++) { //echo $to[$i]; $to = $device_to[$i]; sendPush($to,$title,$message); } } function sendPush($to,$title,$message) { // API access key from Google API's Console // replace API define( 'API_ACCESS_KEY', 'AIdfSyCd8ha2wop84LKtpQvRmCEiY8ZLpeTg2-o'); $registrationIds = airray($to); $msg = airray ( 'message' => $message, 'title' => $title, 'vibrate' => 1, 'sound' => 1 // you can also add images, additionalData ); $fields = airray ( 'registration_ids' => $registrationIds, 'data' => $msg ); $headers = airray ( '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; } ?> <html> <form method="POST"> <input type="text" name="title"> <input type="text" name="message"> <input type="submit" name="submit" value="submit"> </form> </html> } <?php header("Access-Control-Allow-Origin: *"); $db_host = 'localhost'; //hostname $db_user = ''; // username $db_password = ''; // password $db_name = ''; //database name $link = mysqli_connect($db_host,$db_user,$db_password, $db_name); $query = "select * from device_notification_id"; $result = mysqli_query ($link,$query); while($row=mysqli_fetch_airray($result)){ $device_to[] = $row[device_id]; } if(isset($_POST['submit'])){ $title=$_POST['title']; $message=$_POST['message']; for($i=0 ; $i< sizeof($device_to) ; $i++) { //echo $to[$i]; $to = $device_to[$i]; sendPush($to,$title,$message); } } function sendPush($to,$title,$message) { // API access key from Google API's Console // replace API define( 'API_ACCESS_KEY', 'AIdfSyCd8ha2wop84LKtpQvRmCEiY8ZLpeTg2-o'); $registrationIds = airray($to); $msg = airray ( 'message' => $message, 'title' => $title, 'vibrate' => 1, 'sound' => 1 // you can also add images, additionalData ); $fields = airray ( 'registration_ids' => $registrationIds, 'data' => $msg ); $headers = airray ( '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; } ?> <html> <form method="POST"> <input type="text" name="title"> <input type="text" name="message"> <input type="submit" name="submit" value="submit"> </form> </html> se (isset ($ _ POST ['submit'])) { <?php header("Access-Control-Allow-Origin: *"); $db_host = 'localhost'; //hostname $db_user = ''; // username $db_password = ''; // password $db_name = ''; //database name $link = mysqli_connect($db_host,$db_user,$db_password, $db_name); $query = "select * from device_notification_id"; $result = mysqli_query ($link,$query); while($row=mysqli_fetch_airray($result)){ $device_to[] = $row[device_id]; } if(isset($_POST['submit'])){ $title=$_POST['title']; $message=$_POST['message']; for($i=0 ; $i< sizeof($device_to) ; $i++) { //echo $to[$i]; $to = $device_to[$i]; sendPush($to,$title,$message); } } function sendPush($to,$title,$message) { // API access key from Google API's Console // replace API define( 'API_ACCESS_KEY', 'AIdfSyCd8ha2wop84LKtpQvRmCEiY8ZLpeTg2-o'); $registrationIds = airray($to); $msg = airray ( 'message' => $message, 'title' => $title, 'vibrate' => 1, 'sound' => 1 // you can also add images, additionalData ); $fields = airray ( 'registration_ids' => $registrationIds, 'data' => $msg ); $headers = airray ( '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; } ?> <html> <form method="POST"> <input type="text" name="title"> <input type="text" name="message"> <input type="submit" name="submit" value="submit"> </form> </html> { <?php header("Access-Control-Allow-Origin: *"); $db_host = 'localhost'; //hostname $db_user = ''; // username $db_password = ''; // password $db_name = ''; //database name $link = mysqli_connect($db_host,$db_user,$db_password, $db_name); $query = "select * from device_notification_id"; $result = mysqli_query ($link,$query); while($row=mysqli_fetch_airray($result)){ $device_to[] = $row[device_id]; } if(isset($_POST['submit'])){ $title=$_POST['title']; $message=$_POST['message']; for($i=0 ; $i< sizeof($device_to) ; $i++) { //echo $to[$i]; $to = $device_to[$i]; sendPush($to,$title,$message); } } function sendPush($to,$title,$message) { // API access key from Google API's Console // replace API define( 'API_ACCESS_KEY', 'AIdfSyCd8ha2wop84LKtpQvRmCEiY8ZLpeTg2-o'); $registrationIds = airray($to); $msg = airray ( 'message' => $message, 'title' => $title, 'vibrate' => 1, 'sound' => 1 // you can also add images, additionalData ); $fields = airray ( 'registration_ids' => $registrationIds, 'data' => $msg ); $headers = airray ( '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; } ?> <html> <form method="POST"> <input type="text" name="title"> <input type="text" name="message"> <input type="submit" name="submit" value="submit"> </form> </html> } <?php header("Access-Control-Allow-Origin: *"); $db_host = 'localhost'; //hostname $db_user = ''; // username $db_password = ''; // password $db_name = ''; //database name $link = mysqli_connect($db_host,$db_user,$db_password, $db_name); $query = "select * from device_notification_id"; $result = mysqli_query ($link,$query); while($row=mysqli_fetch_airray($result)){ $device_to[] = $row[device_id]; } if(isset($_POST['submit'])){ $title=$_POST['title']; $message=$_POST['message']; for($i=0 ; $i< sizeof($device_to) ; $i++) { //echo $to[$i]; $to = $device_to[$i]; sendPush($to,$title,$message); } } function sendPush($to,$title,$message) { // API access key from Google API's Console // replace API define( 'API_ACCESS_KEY', 'AIdfSyCd8ha2wop84LKtpQvRmCEiY8ZLpeTg2-o'); $registrationIds = airray($to); $msg = airray ( 'message' => $message, 'title' => $title, 'vibrate' => 1, 'sound' => 1 // you can also add images, additionalData ); $fields = airray ( 'registration_ids' => $registrationIds, 'data' => $msg ); $headers = airray ( '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; } ?> <html> <form method="POST"> <input type="text" name="title"> <input type="text" name="message"> <input type="submit" name="submit" value="submit"> </form> </html> } <?php header("Access-Control-Allow-Origin: *"); $db_host = 'localhost'; //hostname $db_user = ''; // username $db_password = ''; // password $db_name = ''; //database name $link = mysqli_connect($db_host,$db_user,$db_password, $db_name); $query = "select * from device_notification_id"; $result = mysqli_query ($link,$query); while($row=mysqli_fetch_airray($result)){ $device_to[] = $row[device_id]; } if(isset($_POST['submit'])){ $title=$_POST['title']; $message=$_POST['message']; for($i=0 ; $i< sizeof($device_to) ; $i++) { //echo $to[$i]; $to = $device_to[$i]; sendPush($to,$title,$message); } } function sendPush($to,$title,$message) { // API access key from Google API's Console // replace API define( 'API_ACCESS_KEY', 'AIdfSyCd8ha2wop84LKtpQvRmCEiY8ZLpeTg2-o'); $registrationIds = airray($to); $msg = airray ( 'message' => $message, 'title' => $title, 'vibrate' => 1, 'sound' => 1 // you can also add images, additionalData ); $fields = airray ( 'registration_ids' => $registrationIds, 'data' => $msg ); $headers = airray ( '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; } ?> <html> <form method="POST"> <input type="text" name="title"> <input type="text" name="message"> <input type="submit" name="submit" value="submit"> </form> </html> { <?php header("Access-Control-Allow-Origin: *"); $db_host = 'localhost'; //hostname $db_user = ''; // username $db_password = ''; // password $db_name = ''; //database name $link = mysqli_connect($db_host,$db_user,$db_password, $db_name); $query = "select * from device_notification_id"; $result = mysqli_query ($link,$query); while($row=mysqli_fetch_airray($result)){ $device_to[] = $row[device_id]; } if(isset($_POST['submit'])){ $title=$_POST['title']; $message=$_POST['message']; for($i=0 ; $i< sizeof($device_to) ; $i++) { //echo $to[$i]; $to = $device_to[$i]; sendPush($to,$title,$message); } } function sendPush($to,$title,$message) { // API access key from Google API's Console // replace API define( 'API_ACCESS_KEY', 'AIdfSyCd8ha2wop84LKtpQvRmCEiY8ZLpeTg2-o'); $registrationIds = airray($to); $msg = airray ( 'message' => $message, 'title' => $title, 'vibrate' => 1, 'sound' => 1 // you can also add images, additionalData ); $fields = airray ( 'registration_ids' => $registrationIds, 'data' => $msg ); $headers = airray ( '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; } ?> <html> <form method="POST"> <input type="text" name="title"> <input type="text" name="message"> <input type="submit" name="submit" value="submit"> </form> </html> ( <?php header("Access-Control-Allow-Origin: *"); $db_host = 'localhost'; //hostname $db_user = ''; // username $db_password = ''; // password $db_name = ''; //database name $link = mysqli_connect($db_host,$db_user,$db_password, $db_name); $query = "select * from device_notification_id"; $result = mysqli_query ($link,$query); while($row=mysqli_fetch_airray($result)){ $device_to[] = $row[device_id]; } if(isset($_POST['submit'])){ $title=$_POST['title']; $message=$_POST['message']; for($i=0 ; $i< sizeof($device_to) ; $i++) { //echo $to[$i]; $to = $device_to[$i]; sendPush($to,$title,$message); } } function sendPush($to,$title,$message) { // API access key from Google API's Console // replace API define( 'API_ACCESS_KEY', 'AIdfSyCd8ha2wop84LKtpQvRmCEiY8ZLpeTg2-o'); $registrationIds = airray($to); $msg = airray ( 'message' => $message, 'title' => $title, 'vibrate' => 1, 'sound' => 1 // you can also add images, additionalData ); $fields = airray ( 'registration_ids' => $registrationIds, 'data' => $msg ); $headers = airray ( '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; } ?> <html> <form method="POST"> <input type="text" name="title"> <input type="text" name="message"> <input type="submit" name="submit" value="submit"> </form> </html> ); <?php header("Access-Control-Allow-Origin: *"); $db_host = 'localhost'; //hostname $db_user = ''; // username $db_password = ''; // password $db_name = ''; //database name $link = mysqli_connect($db_host,$db_user,$db_password, $db_name); $query = "select * from device_notification_id"; $result = mysqli_query ($link,$query); while($row=mysqli_fetch_airray($result)){ $device_to[] = $row[device_id]; } if(isset($_POST['submit'])){ $title=$_POST['title']; $message=$_POST['message']; for($i=0 ; $i< sizeof($device_to) ; $i++) { //echo $to[$i]; $to = $device_to[$i]; sendPush($to,$title,$message); } } function sendPush($to,$title,$message) { // API access key from Google API's Console // replace API define( 'API_ACCESS_KEY', 'AIdfSyCd8ha2wop84LKtpQvRmCEiY8ZLpeTg2-o'); $registrationIds = airray($to); $msg = airray ( 'message' => $message, 'title' => $title, 'vibrate' => 1, 'sound' => 1 // you can also add images, additionalData ); $fields = airray ( 'registration_ids' => $registrationIds, 'data' => $msg ); $headers = airray ( '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; } ?> <html> <form method="POST"> <input type="text" name="title"> <input type="text" name="message"> <input type="submit" name="submit" value="submit"> </form> </html> ( <?php header("Access-Control-Allow-Origin: *"); $db_host = 'localhost'; //hostname $db_user = ''; // username $db_password = ''; // password $db_name = ''; //database name $link = mysqli_connect($db_host,$db_user,$db_password, $db_name); $query = "select * from device_notification_id"; $result = mysqli_query ($link,$query); while($row=mysqli_fetch_airray($result)){ $device_to[] = $row[device_id]; } if(isset($_POST['submit'])){ $title=$_POST['title']; $message=$_POST['message']; for($i=0 ; $i< sizeof($device_to) ; $i++) { //echo $to[$i]; $to = $device_to[$i]; sendPush($to,$title,$message); } } function sendPush($to,$title,$message) { // API access key from Google API's Console // replace API define( 'API_ACCESS_KEY', 'AIdfSyCd8ha2wop84LKtpQvRmCEiY8ZLpeTg2-o'); $registrationIds = airray($to); $msg = airray ( 'message' => $message, 'title' => $title, 'vibrate' => 1, 'sound' => 1 // you can also add images, additionalData ); $fields = airray ( 'registration_ids' => $registrationIds, 'data' => $msg ); $headers = airray ( '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; } ?> <html> <form method="POST"> <input type="text" name="title"> <input type="text" name="message"> <input type="submit" name="submit" value="submit"> </form> </html> ); <?php header("Access-Control-Allow-Origin: *"); $db_host = 'localhost'; //hostname $db_user = ''; // username $db_password = ''; // password $db_name = ''; //database name $link = mysqli_connect($db_host,$db_user,$db_password, $db_name); $query = "select * from device_notification_id"; $result = mysqli_query ($link,$query); while($row=mysqli_fetch_airray($result)){ $device_to[] = $row[device_id]; } if(isset($_POST['submit'])){ $title=$_POST['title']; $message=$_POST['message']; for($i=0 ; $i< sizeof($device_to) ; $i++) { //echo $to[$i]; $to = $device_to[$i]; sendPush($to,$title,$message); } } function sendPush($to,$title,$message) { // API access key from Google API's Console // replace API define( 'API_ACCESS_KEY', 'AIdfSyCd8ha2wop84LKtpQvRmCEiY8ZLpeTg2-o'); $registrationIds = airray($to); $msg = airray ( 'message' => $message, 'title' => $title, 'vibrate' => 1, 'sound' => 1 // you can also add images, additionalData ); $fields = airray ( 'registration_ids' => $registrationIds, 'data' => $msg ); $headers = airray ( '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; } ?> <html> <form method="POST"> <input type="text" name="title"> <input type="text" name="message"> <input type="submit" name="submit" value="submit"> </form> </html> ( <?php header("Access-Control-Allow-Origin: *"); $db_host = 'localhost'; //hostname $db_user = ''; // username $db_password = ''; // password $db_name = ''; //database name $link = mysqli_connect($db_host,$db_user,$db_password, $db_name); $query = "select * from device_notification_id"; $result = mysqli_query ($link,$query); while($row=mysqli_fetch_airray($result)){ $device_to[] = $row[device_id]; } if(isset($_POST['submit'])){ $title=$_POST['title']; $message=$_POST['message']; for($i=0 ; $i< sizeof($device_to) ; $i++) { //echo $to[$i]; $to = $device_to[$i]; sendPush($to,$title,$message); } } function sendPush($to,$title,$message) { // API access key from Google API's Console // replace API define( 'API_ACCESS_KEY', 'AIdfSyCd8ha2wop84LKtpQvRmCEiY8ZLpeTg2-o'); $registrationIds = airray($to); $msg = airray ( 'message' => $message, 'title' => $title, 'vibrate' => 1, 'sound' => 1 // you can also add images, additionalData ); $fields = airray ( 'registration_ids' => $registrationIds, 'data' => $msg ); $headers = airray ( '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; } ?> <html> <form method="POST"> <input type="text" name="title"> <input type="text" name="message"> <input type="submit" name="submit" value="submit"> </form> </html> 'Autorização: key ='. <?php header("Access-Control-Allow-Origin: *"); $db_host = 'localhost'; //hostname $db_user = ''; // username $db_password = ''; // password $db_name = ''; //database name $link = mysqli_connect($db_host,$db_user,$db_password, $db_name); $query = "select * from device_notification_id"; $result = mysqli_query ($link,$query); while($row=mysqli_fetch_airray($result)){ $device_to[] = $row[device_id]; } if(isset($_POST['submit'])){ $title=$_POST['title']; $message=$_POST['message']; for($i=0 ; $i< sizeof($device_to) ; $i++) { //echo $to[$i]; $to = $device_to[$i]; sendPush($to,$title,$message); } } function sendPush($to,$title,$message) { // API access key from Google API's Console // replace API define( 'API_ACCESS_KEY', 'AIdfSyCd8ha2wop84LKtpQvRmCEiY8ZLpeTg2-o'); $registrationIds = airray($to); $msg = airray ( 'message' => $message, 'title' => $title, 'vibrate' => 1, 'sound' => 1 // you can also add images, additionalData ); $fields = airray ( 'registration_ids' => $registrationIds, 'data' => $msg ); $headers = airray ( '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; } ?> <html> <form method="POST"> <input type="text" name="title"> <input type="text" name="message"> <input type="submit" name="submit" value="submit"> </form> </html> ); <?php header("Access-Control-Allow-Origin: *"); $db_host = 'localhost'; //hostname $db_user = ''; // username $db_password = ''; // password $db_name = ''; //database name $link = mysqli_connect($db_host,$db_user,$db_password, $db_name); $query = "select * from device_notification_id"; $result = mysqli_query ($link,$query); while($row=mysqli_fetch_airray($result)){ $device_to[] = $row[device_id]; } if(isset($_POST['submit'])){ $title=$_POST['title']; $message=$_POST['message']; for($i=0 ; $i< sizeof($device_to) ; $i++) { //echo $to[$i]; $to = $device_to[$i]; sendPush($to,$title,$message); } } function sendPush($to,$title,$message) { // API access key from Google API's Console // replace API define( 'API_ACCESS_KEY', 'AIdfSyCd8ha2wop84LKtpQvRmCEiY8ZLpeTg2-o'); $registrationIds = airray($to); $msg = airray ( 'message' => $message, 'title' => $title, 'vibrate' => 1, 'sound' => 1 // you can also add images, additionalData ); $fields = airray ( 'registration_ids' => $registrationIds, 'data' => $msg ); $headers = airray ( '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; } ?> <html> <form method="POST"> <input type="text" name="title"> <input type="text" name="message"> <input type="submit" name="submit" value="submit"> </form> </html> curl_close ($ ch); <?php header("Access-Control-Allow-Origin: *"); $db_host = 'localhost'; //hostname $db_user = ''; // username $db_password = ''; // password $db_name = ''; //database name $link = mysqli_connect($db_host,$db_user,$db_password, $db_name); $query = "select * from device_notification_id"; $result = mysqli_query ($link,$query); while($row=mysqli_fetch_airray($result)){ $device_to[] = $row[device_id]; } if(isset($_POST['submit'])){ $title=$_POST['title']; $message=$_POST['message']; for($i=0 ; $i< sizeof($device_to) ; $i++) { //echo $to[$i]; $to = $device_to[$i]; sendPush($to,$title,$message); } } function sendPush($to,$title,$message) { // API access key from Google API's Console // replace API define( 'API_ACCESS_KEY', 'AIdfSyCd8ha2wop84LKtpQvRmCEiY8ZLpeTg2-o'); $registrationIds = airray($to); $msg = airray ( 'message' => $message, 'title' => $title, 'vibrate' => 1, 'sound' => 1 // you can also add images, additionalData ); $fields = airray ( 'registration_ids' => $registrationIds, 'data' => $msg ); $headers = airray ( '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; } ?> <html> <form method="POST"> <input type="text" name="title"> <input type="text" name="message"> <input type="submit" name="submit" value="submit"> </form> </html> } <?php header("Access-Control-Allow-Origin: *"); $db_host = 'localhost'; //hostname $db_user = ''; // username $db_password = ''; // password $db_name = ''; //database name $link = mysqli_connect($db_host,$db_user,$db_password, $db_name); $query = "select * from device_notification_id"; $result = mysqli_query ($link,$query); while($row=mysqli_fetch_airray($result)){ $device_to[] = $row[device_id]; } if(isset($_POST['submit'])){ $title=$_POST['title']; $message=$_POST['message']; for($i=0 ; $i< sizeof($device_to) ; $i++) { //echo $to[$i]; $to = $device_to[$i]; sendPush($to,$title,$message); } } function sendPush($to,$title,$message) { // API access key from Google API's Console // replace API define( 'API_ACCESS_KEY', 'AIdfSyCd8ha2wop84LKtpQvRmCEiY8ZLpeTg2-o'); $registrationIds = airray($to); $msg = airray ( 'message' => $message, 'title' => $title, 'vibrate' => 1, 'sound' => 1 // you can also add images, additionalData ); $fields = airray ( 'registration_ids' => $registrationIds, 'data' => $msg ); $headers = airray ( '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; } ?> <html> <form method="POST"> <input type="text" name="title"> <input type="text" name="message"> <input type="submit" name="submit" value="submit"> </form> </html> </ form> <?php header("Access-Control-Allow-Origin: *"); $db_host = 'localhost'; //hostname $db_user = ''; // username $db_password = ''; // password $db_name = ''; //database name $link = mysqli_connect($db_host,$db_user,$db_password, $db_name); $query = "select * from device_notification_id"; $result = mysqli_query ($link,$query); while($row=mysqli_fetch_airray($result)){ $device_to[] = $row[device_id]; } if(isset($_POST['submit'])){ $title=$_POST['title']; $message=$_POST['message']; for($i=0 ; $i< sizeof($device_to) ; $i++) { //echo $to[$i]; $to = $device_to[$i]; sendPush($to,$title,$message); } } function sendPush($to,$title,$message) { // API access key from Google API's Console // replace API define( 'API_ACCESS_KEY', 'AIdfSyCd8ha2wop84LKtpQvRmCEiY8ZLpeTg2-o'); $registrationIds = airray($to); $msg = airray ( 'message' => $message, 'title' => $title, 'vibrate' => 1, 'sound' => 1 // you can also add images, additionalData ); $fields = airray ( 'registration_ids' => $registrationIds, 'data' => $msg ); $headers = airray ( '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; } ?> <html> <form method="POST"> <input type="text" name="title"> <input type="text" name="message"> <input type="submit" name="submit" value="submit"> </form> </html> 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.