Skip to content

PiR-Alain/php-gcm

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

62 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

php-gcm

Build Status

Why

Google Cloud Messaging for Android is very powerful, but there are a lot of details to handle. This library takes care of the details and makes GCM very easy to use with PHP.

Support

php-gcm supports the HTTP server protocol for GCM. There is not currently support for XMPP, but implementations and pull requests for XMPP are welcome. See #3 for more details.

php-gcm supports PHP versions >= 5.3.10. php-gcm may work on older versions of PHP, but has not been tested on them.

Install

Composer is the easiest way to manage dependencies in your project. Create a file named composer.json with the following:

{
    "require": {
        "php-gcm/php-gcm": "^1.1.1"
    }
}

And run Composer to install php-gcm:

$ curl -s http://getcomposer.org/installer | php
$ composer.phar install

Usage

$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
}

License

php-gcm is licensed under the Apache 2.0 License. See the LICENSE file for more details.

About

A loose port of Google's gcm-server library to PHP

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 99.9%
  • Shell 0.1%