PHP code example of php-gcm / php-gcm

1. Go to this page and download the library: Download php-gcm/php-gcm 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/ */

    

php-gcm / php-gcm example snippets


$sender = new Sender($gcmApiKey);
$message = new Message($collapseKey, $payloadData);

try {
    $result = $sender->send($message, $deviceRegistrationId, $numberOfRetryAttempts);
} catch (\InvalidArgumentException $e) {
    // $deviceRegistrationId was null
} catch (PHP_GCM\InvalidRequestException $e) {
    // server returned HTTP code other than 200 or 503
} catch (\Exception $e) {
    // message could not be sent
}
json
{
    "hp-gcm/php-gcm": "^1.1.1"
    }
}
json
{
    "hp-gcm/php-gcm": "dev-master"
    }
}