2017 © Pedro Peláez
 

library jpush

JPush API PHP Client

image

jpush/jpush

JPush API PHP Client

  • Tuesday, June 19, 2018
  • by jpush
  • Repository
  • 39 Watchers
  • 328 Stars
  • 131,399 Installations
  • PHP
  • 29 Dependents
  • 0 Suggesters
  • 137 Forks
  • 0 Open issues
  • 67 Versions
  • 12 % Grown

The README.md

JPush API PHP Client

这是 JPush REST API 的 PHP 版本封装开发包,是由极光推送官方提供的,一般支持最新的 API 功能。, (*1)

对应的 REST API 文档: https://docs.jiguang.cn/jpush/server/push/server_overview/, (*2)

支持的 PHP 版本: 5.3.3 ~ 5.6.x, 7.x, (*3)

若需要兼容 PHP 5.3.3 以下版本,可以使用 v3 分支的代码。 因为运行 Composer 需要 PHP 5.3.2+ 以上版本,所以其不提供 Composer 支持, 也可以点击链接下载 v3.4.x 版本源码。, (*4)

Installation

使用 Composer 安装

  • 执行 $ php composer.phar install$ composer install 进行安装。

直接下载源码安装

直接下载源代码也是一种安装 SDK 的方法,不过因为有版本更新的维护问题,所以这种安装方式十分不推荐,但由于种种原因导致无法使用 Composer,所以我们也提供了这种情况下的备选方案。, (*5)

  • 下载源代码包,解压到项目中
  • 在项目中引入 autoload:
require 'path_to_sdk/autoload.php';

Usage

初始化

use JPush\Client as JPush;
...
...

    $client = new JPush($app_key, $master_secret);

...

OR, (*6)

$client = new \JPush\Client($app_key, $master_secret);

简单推送

$client->push()
    ->setPlatform('all')
    ->addAllAudience()
    ->setNotificationAlert('Hello, JPush')
    ->send();

异常处理

$pusher = $client->push();
$pusher->setPlatform('all');
$pusher->addAllAudience();
$pusher->setNotificationAlert('Hello, JPush');
try {
    $pusher->send();
} catch (\JPush\Exceptions\JPushException $e) {
    // try something else here
    print $e;
}

Examples

注意: 这只是使用样例, 不应该直接用于实际环境中!!, (*7)

在下载的中的 examples 文件夹有简单示例代码, 开发者可以参考其中的样例快速了解该库的使用方法。, (*8)

简单使用方法, (*9)

先填写对应的appKey和masterSecret,可以额外设定Registration_id。, (*10)

若要运行 push_example.php 中的示例代码:, (*11)

``` bash, (*12)

假定当前目录为 JPush 源码所在的根目录

$ php examples/push_example.php, (*13)

> 同时也可编辑相关的示例文件,更改参数查看执行效果

## Testing

```bash
# 编辑 tests/bootstrap.php 文件,填入必须的变量值
# OR 设置相应的环境变量

# 运行全部测试用例
$ composer tests

# 运行某一具体测试用例
$ composer tests/JPush/xxTest.php

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/jpush/jpush-api-php-client., (*14)

License

The library is available as open source under the terms of the MIT License., (*15)

The Versions

19/06 2018

dev-master

9999999-dev https://github.com/jpush/jpush-api-php-client

JPush API PHP Client

  Sources   Download

MIT

The Requires

  • ext-curl *
  • php >=5.3.3

 

The Development Requires

19/06 2018

dev-dev

dev-dev https://github.com/jpush/jpush-api-php-client

JPush API PHP Client

  Sources   Download

MIT

The Requires

  • ext-curl *
  • php >=5.3.3

 

The Development Requires

30/05 2018

v3.6.1

3.6.1.0 https://github.com/jpush/jpush-api-php-client

JPush API PHP Client

  Sources   Download

MIT

The Requires

  • php >=5.3.3
  • ext-curl *

 

The Development Requires

28/05 2018

v3.6.0

3.6.0.0 https://github.com/jpush/jpush-api-php-client

JPush API PHP Client

  Sources   Download

MIT

The Requires

  • php >=5.3.3
  • ext-curl *

 

The Development Requires

10/05 2018

v3.5.37

3.5.37.0 https://github.com/jpush/jpush-api-php-client

JPush API PHP Client

  Sources   Download

MIT

The Requires

  • php >=5.3.3
  • ext-curl *

 

The Development Requires

08/04 2018

v3.5.36

3.5.36.0 https://github.com/jpush/jpush-api-php-client

JPush API PHP Client

  Sources   Download

MIT

The Requires

  • php >=5.3.3
  • ext-curl *

 

The Development Requires

03/04 2018

v3.5.35

3.5.35.0 https://github.com/jpush/jpush-api-php-client

JPush API PHP Client

  Sources   Download

MIT

The Requires

  • php >=5.3.3
  • ext-curl *

 

The Development Requires

09/03 2018

v3.5.34

3.5.34.0 https://github.com/jpush/jpush-api-php-client

JPush API PHP Client

  Sources   Download

MIT

The Requires

  • php >=5.3.3
  • ext-curl *

 

The Development Requires

06/03 2018

v3.5.33

3.5.33.0 https://github.com/jpush/jpush-api-php-client

JPush API PHP Client

  Sources   Download

MIT

The Requires

  • php >=5.3.3
  • ext-curl *

 

The Development Requires

02/02 2018

v3.5.32

3.5.32.0 https://github.com/jpush/jpush-api-php-client

JPush API PHP Client

  Sources   Download

MIT

The Requires

  • php >=5.3.3
  • ext-curl *

 

The Development Requires

30/01 2018

v3.5.31

3.5.31.0 https://github.com/jpush/jpush-api-php-client

JPush API PHP Client

  Sources   Download

MIT

The Requires

  • php >=5.3.3
  • ext-curl *

 

The Development Requires

19/01 2018

v3.5.30

3.5.30.0 https://github.com/jpush/jpush-api-php-client

JPush API PHP Client

  Sources   Download

MIT

The Requires

  • php >=5.3.3
  • ext-curl *

 

The Development Requires

18/01 2018

v3.5.29

3.5.29.0 https://github.com/jpush/jpush-api-php-client

JPush API PHP Client

  Sources   Download

MIT

The Requires

  • php >=5.3.3
  • ext-curl *

 

The Development Requires

18/01 2018

v3.5.28

3.5.28.0 https://github.com/jpush/jpush-api-php-client

JPush API PHP Client

  Sources   Download

MIT

The Requires

  • php >=5.3.3
  • ext-curl *

 

The Development Requires

09/01 2018

v3.5.27

3.5.27.0 https://github.com/jpush/jpush-api-php-client

JPush API PHP Client

  Sources   Download

MIT

The Requires

  • php >=5.3.3
  • ext-curl *

 

The Development Requires

08/01 2018

v3.5.26

3.5.26.0 https://github.com/jpush/jpush-api-php-client

JPush API PHP Client

  Sources   Download

MIT

The Requires

  • php >=5.3.3
  • ext-curl *

 

The Development Requires

08/01 2018

v3.5.25

3.5.25.0 https://github.com/jpush/jpush-api-php-client

JPush API PHP Client

  Sources   Download

MIT

The Requires

  • php >=5.3.3
  • ext-curl *

 

The Development Requires

15/12 2017

v3.5.24

3.5.24.0 https://github.com/jpush/jpush-api-php-client

JPush API PHP Client

  Sources   Download

MIT

The Requires

  • php >=5.3.3
  • ext-curl *

 

The Development Requires

16/10 2017

v3.5.23

3.5.23.0 https://github.com/jpush/jpush-api-php-client

JPush API PHP Client

  Sources   Download

MIT

The Requires

  • php >=5.3.3
  • ext-curl *

 

The Development Requires

01/08 2017

v3.5.22

3.5.22.0 https://github.com/jpush/jpush-api-php-client

JPush API PHP Client

  Sources   Download

MIT

The Requires

  • php >=5.3.3
  • ext-curl *

 

The Development Requires

12/07 2017

v3.5.21

3.5.21.0 https://github.com/jpush/jpush-api-php-client

JPush API PHP Client

  Sources   Download

MIT

The Requires

  • php >=5.3.3
  • ext-curl *

 

The Development Requires

10/07 2017

v3.5.20

3.5.20.0 https://github.com/jpush/jpush-api-php-client

JPush API PHP Client

  Sources   Download

MIT

The Requires

  • php >=5.3.3
  • ext-curl *

 

The Development Requires

29/06 2017

v3.5.19

3.5.19.0 https://github.com/jpush/jpush-api-php-client

JPush API PHP Client

  Sources   Download

MIT

The Requires

  • php >=5.3.3
  • ext-curl *

 

The Development Requires

28/06 2017

v3.5.18

3.5.18.0 https://github.com/jpush/jpush-api-php-client

JPush API PHP Client

  Sources   Download

MIT

The Requires

  • php >=5.3.3
  • ext-curl *

 

The Development Requires

21/06 2017

v3.5.17

3.5.17.0 https://github.com/jpush/jpush-api-php-client

JPush API PHP Client

  Sources   Download

MIT

The Requires

  • php >=5.3.3
  • ext-curl *

 

The Development Requires

18/05 2017

v3.5.16

3.5.16.0 https://github.com/jpush/jpush-api-php-client

JPush API PHP Client

  Sources   Download

MIT

The Requires

  • php >=5.3.3
  • ext-curl *

 

The Development Requires

05/04 2017

v3.5.15

3.5.15.0 https://github.com/jpush/jpush-api-php-client

JPush API PHP Client

  Sources   Download

MIT

The Requires

  • php >=5.3.3
  • ext-curl *

 

The Development Requires

23/03 2017

v3.5.14

3.5.14.0 https://github.com/jpush/jpush-api-php-client

JPush API PHP Client

  Sources   Download

MIT

The Requires

  • php >=5.3.3
  • ext-curl *

 

The Development Requires

20/03 2017

v3.5.13

3.5.13.0 https://github.com/jpush/jpush-api-php-client

JPush API PHP Client

  Sources   Download

MIT

The Requires

  • php >=5.3.3
  • ext-curl *

 

The Development Requires

27/02 2017

v3.5.12

3.5.12.0 https://github.com/jpush/jpush-api-php-client

JPush API PHP Client

  Sources   Download

MIT

The Requires

  • php >=5.3.3
  • ext-curl *

 

The Development Requires

14/02 2017

v3.5.11

3.5.11.0 https://github.com/jpush/jpush-api-php-client

JPush API PHP Client

  Sources   Download

MIT

The Requires

  • php >=5.3.3
  • ext-curl *

 

The Development Requires

24/01 2017

v3.x-dev

3.9999999.9999999.9999999-dev http://docs.jpush.cn/display/dev/Push-API-v3

JPush API PHP Client

  Sources   Download

Apache

The Requires

  • php >=5.1
  • ext-curl *

 

The Development Requires

24/01 2017

v3.4.4

3.4.4.0 http://docs.jpush.cn/display/dev/Push-API-v3

JPush API PHP Client

  Sources   Download

Apache

The Requires

  • php >=5.1
  • ext-curl *

 

The Development Requires

24/01 2017

v3.5.10

3.5.10.0 https://github.com/jpush/jpush-api-php-client

JPush API PHP Client

  Sources   Download

MIT

The Requires

  • php >=5.3.3
  • ext-curl *

 

The Development Requires

04/01 2017

v3.5.9

3.5.9.0 https://github.com/jpush/jpush-api-php-client

JPush API PHP Client

  Sources   Download

MIT

The Requires

  • php >=5.3.3
  • ext-curl *

 

The Development Requires

27/12 2016

v3.5.8

3.5.8.0 https://github.com/jpush/jpush-api-php-client

JPush API PHP Client

  Sources   Download

MIT

The Requires

  • php >=5.3.3
  • ext-curl *

 

The Development Requires

20/12 2016

v3.5.7

3.5.7.0 https://github.com/jpush/jpush-api-php-client

JPush API PHP Client

  Sources   Download

MIT

The Requires

  • php >=5.3.3
  • ext-curl *

 

The Development Requires

16/11 2016

v3.5.6

3.5.6.0 https://github.com/jpush/jpush-api-php-client

JPush API PHP Client

  Sources   Download

MIT

The Requires

  • php >=5.3.3
  • ext-curl *

 

The Development Requires

04/11 2016

v3.5.5

3.5.5.0 https://github.com/jpush/jpush-api-php-client

JPush API PHP Client

  Sources   Download

MIT

The Requires

  • php >=5.3.3
  • ext-curl *

 

The Development Requires

25/10 2016

v3.5.4

3.5.4.0 https://github.com/jpush/jpush-api-php-client

JPush API PHP Client

  Sources   Download

MIT

The Requires

  • php >=5.3.3
  • ext-curl *

 

The Development Requires

20/10 2016

v3.5.3

3.5.3.0 https://github.com/jpush/jpush-api-php-client

JPush API PHP Client

  Sources   Download

MIT

The Requires

  • php >=5.3.3
  • ext-curl *

 

The Development Requires

20/09 2016

v3.5.2

3.5.2.0 https://github.com/jpush/jpush-api-php-client

JPush API PHP Client

  Sources   Download

MIT

The Requires

  • php >=5.3.3
  • ext-curl *

 

The Development Requires

28/08 2016

v3.5.1

3.5.1.0 https://github.com/jpush/jpush-api-php-client

JPush API PHP Client

  Sources   Download

MIT

The Requires

  • php >=5.3.3
  • ext-curl *

 

The Development Requires

27/07 2016

v3.5.0

3.5.0.0 https://github.com/jpush/jpush-api-php-client

JPush API PHP Client

  Sources   Download

MIT

The Requires

  • php >=5.3.3
  • ext-curl *

 

The Development Requires

23/06 2016

v3.4.3

3.4.3.0 http://docs.jpush.cn/display/dev/Push-API-v3

JPush API PHP Client

  Sources   Download

Apache

The Requires

  • php >=5.1
  • ext-curl *

 

The Development Requires

31/05 2016

v3.4.2

3.4.2.0 http://docs.jpush.cn/display/dev/Push-API-v3

JPush API PHP Client

  Sources   Download

Apache

The Requires

  • php >=5.1
  • ext-curl *

 

The Development Requires

30/05 2016

v3.4.1

3.4.1.0 http://docs.jpush.cn/display/dev/Push-API-v3

JPush API PHP Client

  Sources   Download

Apache

The Requires

  • php >=5.1
  • ext-curl *

 

The Development Requires

26/05 2016

v3.4.0

3.4.0.0 http://docs.jpush.cn/display/dev/Push-API-v3

JPush API PHP Client

  Sources   Download

Apache

The Requires

  • php >=5.1
  • ext-curl *

 

The Development Requires

07/04 2016

v3.3.9

3.3.9.0 http://docs.jpush.cn/display/dev/Push-API-v3

JPush API PHP Client

  Sources   Download

Apache

The Requires

  • php >=5.1
  • ext-curl *

 

The Development Requires

09/03 2016

v3.3.8

3.3.8.0 http://docs.jpush.cn/display/dev/Push-API-v3

JPush API PHP Client

  Sources   Download

Apache

The Development Requires

22/01 2016

v3.3.7

3.3.7.0 http://docs.jpush.cn/display/dev/Push-API-v3

JPush API PHP Client

  Sources   Download

Apache

The Development Requires

14/01 2016

v3.3.6

3.3.6.0 http://docs.jpush.cn/display/dev/Push-API-v3

JPush API PHP Client

  Sources   Download

Apache

The Development Requires

07/01 2016

v3.3.5

3.3.5.0 http://docs.jpush.cn/display/dev/Push-API-v3

JPush API PHP Client

  Sources   Download

Apache

The Development Requires

05/01 2016

v3.3.4

3.3.4.0 http://docs.jpush.cn/display/dev/Push-API-v3

JPush API PHP Client

  Sources   Download

Apache

The Development Requires

04/01 2016

v3.3.3

3.3.3.0 http://docs.jpush.cn/display/dev/Push-API-v3

JPush API PHP Client

  Sources   Download

Apache

The Development Requires

23/12 2015

v3.3.2

3.3.2.0 http://docs.jpush.cn/display/dev/Push-API-v3

JPush API PHP Client

  Sources   Download

Apache

The Development Requires

23/12 2015

v3.3.1

3.3.1.0 http://docs.jpush.cn/display/dev/Push-API-v3

JPush API PHP Client

  Sources   Download

Apache

The Development Requires

22/12 2015

v3.3.0

3.3.0.0 http://docs.jpush.cn/display/dev/Push-API-v3

JPush API PHP Client

  Sources   Download

Apache

The Development Requires

08/09 2015

v3.2.5

3.2.5.0 http://docs.jpush.cn/display/dev/Push-API-v3

JPush API PHP Client

  Sources   Download

Apache

The Requires

 

The Development Requires

10/08 2015

v3.2.4

3.2.4.0 http://docs.jpush.cn/display/dev/Push-API-v3

JPush API PHP Client

  Sources   Download

Apache

The Requires

 

The Development Requires

02/03 2015

v3.2.3

3.2.3.0 http://docs.jpush.cn/display/dev/Push-API-v3

JPush API PHP Client

  Sources   Download

Apache

The Requires

 

The Development Requires

03/02 2015

v3.2.2

3.2.2.0 http://docs.jpush.cn/display/dev/Push-API-v3

JPush API PHP Client

  Sources   Download

Apache

The Requires

 

The Development Requires

03/12 2014

v3.2.1

3.2.1.0 http://docs.jpush.cn/display/dev/Push-API-v3

JPush API PHP Client

  Sources   Download

Apache

The Requires

 

The Development Requires

30/10 2014

v3.2.0

3.2.0.0 http://docs.jpush.cn/display/dev/Push-API-v3

JPush API PHP Client

  Sources   Download

Apache

The Requires

 

The Development Requires

27/08 2014

v3.1.2

3.1.2.0 http://docs.jpush.cn/display/dev/Push-API-v3

JPush API PHP Client

  Sources   Download

Apache

The Requires

 

The Development Requires

04/07 2014

v3.1.1

3.1.1.0 http://docs.jpush.cn/display/dev/Push-API-v3

JPush API PHP Client

  Sources   Download

Apache

The Requires

 

The Development Requires

28/06 2014

v3.1.0

3.1.0.0 http://docs.jpush.cn/display/dev/Push-API-v3

JPush API PHP Client

  Sources   Download

Apache

The Requires

 

The Development Requires