doc
1 year ago
lib
2 months ago
tests
1 year ago
.coveralls.yml
1 year ago
.git
1 year ago
.gitignore
1 year ago
.travis.yml
1 year ago
LICENSE.txt
1 year ago
README.md
1 year ago
build.php
1 year ago
composer.json
1 year ago
init.php
5 months ago
overview.md
1 year ago
phpunit.no_autoload.xml
1 year ago
phpunit.xml
1 year ago
release.php
1 year ago
test
1 year ago
README.md
136 lines
| 1 | WonderPush PHP library |
| 2 | ====================== |
| 3 | |
| 4 | [](https://travis-ci.org/wonderpush/wonderpush-php-lib](https://travis-ci.org/wonderpush/wonderpush-php-lib](https://travis-ci.org/wonderpush/wonderpush-php-lib) |
| 5 | [](https://packagist.org/packages/wonderpush/wonderpush-php-lib](https://packagist.org/packages/wonderpush/wonderpush-php-lib](https://packagist.org/packages/wonderpush/wonderpush-php-lib) |
| 6 | [](https://packagist.org/packages/wonderpush/wonderpush-php-lib](https://packagist.org/packages/wonderpush/wonderpush-php-lib](https://packagist.org/packages/wonderpush/wonderpush-php-lib) |
| 7 | [](https://coveralls.io/github/wonderpush/wonderpush-php-lib?branch=master](https://coveralls.io/github/wonderpush/wonderpush-php-lib?branch=master](https://coveralls.io/github/wonderpush/wonderpush-php-lib?branch=master) |
| 8 | |
| 9 | Find the full WonderPush services documentation at: |
| 10 | https://docs.wonderpush.com/docs. |
| 11 | |
| 12 | |
| 13 | |
| 14 | ## Introduction |
| 15 | |
| 16 | This project contain a PHP library for interacting with the WonderPush services. |
| 17 | It helps you performing calls to the Management API. This contrasts with the SDKs, which are targeted at being integrated within your apps and handle interactions with the users. |
| 18 | |
| 19 | |
| 20 | ### APIs |
| 21 | |
| 22 | WonderPush comes as two APIs, one aimed at the user devices, and the other optional one aimed at your servers and tools. |
| 23 | The former is simply called the REST API, whereas the latter is called the Management API. |
| 24 | |
| 25 | This tool helps you performing calls to the Management API. |
| 26 | |
| 27 | #### Management API Reference |
| 28 | |
| 29 | All references for the WonderPush Management API are available on the WonderPush documentation pages: |
| 30 | https://docs.wonderpush.com/reference. |
| 31 | |
| 32 | |
| 33 | |
| 34 | ## Documentation |
| 35 | |
| 36 | Please see https://wonderpush.github.io/wonderpush-php-lib for up-to-date documentation. |
| 37 | |
| 38 | |
| 39 | |
| 40 | ## Requirements |
| 41 | |
| 42 | PHP 5.3.3 and later. |
| 43 | |
| 44 | |
| 45 | |
| 46 | ## Composer |
| 47 | |
| 48 | You can install the bindings via [](http://getcomposer.org/Composer](http://getcomposer.org/](http://getcomposer.org/). Run the following command: |
| 49 | |
| 50 | ```bash |
| 51 | composer require wonderpush/wonderpush-php-lib |
| 52 | ``` |
| 53 | |
| 54 | To use the bindings, use Composer's [](https://getcomposer.org/doc/00-intro.md#autoloadingautoload](https://getcomposer.org/doc/00-intro.md#autoloading](https://getcomposer.org/doc/00-intro.md#autoloading): |
| 55 | |
| 56 | ```php |
| 57 | require_once('vendor/autoload.php'); |
| 58 | ``` |
| 59 | |
| 60 | |
| 61 | |
| 62 | ## Manual Installation |
| 63 | |
| 64 | If you do not wish to use Composer, you can download the [](https://github.com/wonderpush/wonderpush-php-lib/releaseslatest release](https://github.com/wonderpush/wonderpush-php-lib/releases](https://github.com/wonderpush/wonderpush-php-lib/releases). |
| 65 | Then, to use the bindings, include the `init.php` file. |
| 66 | |
| 67 | ```php |
| 68 | require_once('/path/to/wonderpush-php-lib/init.php'); |
| 69 | ``` |
| 70 | |
| 71 | |
| 72 | |
| 73 | ## Dependencies |
| 74 | |
| 75 | The bindings require the following extension in order to work properly: |
| 76 | |
| 77 | - [](https://secure.php.net/manual/en/book.curl.php`curl`](https://secure.php.net/manual/en/book.curl.php](https://secure.php.net/manual/en/book.curl.php) |
| 78 | - [](https://secure.php.net/manual/en/book.json.php`json`](https://secure.php.net/manual/en/book.json.php](https://secure.php.net/manual/en/book.json.php) |
| 79 | |
| 80 | If you use Composer, these dependencies should be handled automatically. If you install manually, you'll want to make sure that these extensions are available. |
| 81 | |
| 82 | |
| 83 | |
| 84 | ## Getting Started |
| 85 | |
| 86 | Simple usage looks like: |
| 87 | |
| 88 | ```php |
| 89 | $wonderpush = new \WonderPush\WonderPush(WONDERPUSH_ACCESS_TOKEN, WONDERPUSH_APPLICATION_ID); |
| 90 | $response = $wonderpush->deliveries()->create( |
| 91 | \WonderPush\Params\DeliveriesCreateParams::_new() |
| 92 | ->setTargetSegmentIds('@ALL') |
| 93 | ->setNotification(\WonderPush\Obj\Notification::_new() |
| 94 | ->setAlert(\WonderPush\Obj\NotificationAlert::_new() |
| 95 | ->setTitle('Using the PHP library') |
| 96 | ->setText('Hello, WonderPush!') |
| 97 | )) |
| 98 | ); |
| 99 | echo $response->getNotificationId(); |
| 100 | ``` |
| 101 | |
| 102 | |
| 103 | ### Configuring a Logger |
| 104 | |
| 105 | The library does minimal logging, but it can be configured with a [](http://www.php-fig.org/psr/psr-3/`PSR-3` compatible logger](http://www.php-fig.org/psr/psr-3/](http://www.php-fig.org/psr/psr-3/) so that messages end up there instead of `error_log`: |
| 106 | |
| 107 | ```php |
| 108 | $wonderpush->setLogger($logger); |
| 109 | ``` |
| 110 | |
| 111 | |
| 112 | |
| 113 | ## Development |
| 114 | |
| 115 | Install dependencies: |
| 116 | |
| 117 | ``` bash |
| 118 | composer install |
| 119 | ``` |
| 120 | |
| 121 | |
| 122 | |
| 123 | ## Tests |
| 124 | |
| 125 | Install dependencies as mentioned above (which will resolve [](http://packagist.org/packages/phpunit/phpunitPHPUnit](http://packagist.org/packages/phpunit/phpunit](http://packagist.org/packages/phpunit/phpunit)), then you can run the test suite: |
| 126 | |
| 127 | ```bash |
| 128 | ./test |
| 129 | ``` |
| 130 | |
| 131 | Or to run an individual test file: |
| 132 | |
| 133 | ```bash |
| 134 | vendor/bin/phpunit tests/SomeTest.php |
| 135 | ``` |
| 136 |