PHP code example of webpower / gcm-application-server
1. Go to this page and download the library: Download webpower/gcm-application-server library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
webpower / gcm-application-server example snippets
$sender = new \WebPower\gcm\server\Sender('your google cloud messaging api key');
$message = \WebPower\gcm\server\Message::builder()
->addData('message', 'Hoi')
->build();
// Send to a single device using text/plain
$result = $sender->singleSendNoRetry($message, 'registration id');
// or to multiple devices using application/json
$result = $sender->sendNoRetry($message, array('registration id', 'another registration id'));
echo $result; // all value objects support __toString just like the Java code