Skip to content
This repository has been archived by the owner on Oct 27, 2019. It is now read-only.

lkorth/php-gcm

Repository files navigation

php-gcm

Build Status Total Downloads

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

Latest

php-gcm follows SEMVER. If you would like to try out the latest, possibly unstable or incorrect code, the dependency can be pointed to dev-master.

{
    "require": {
        "php-gcm/php-gcm": "dev-master"
    }
}

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

An easy to use gcm library for PHP

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages