PHP code example of banbans / jpush

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

    

banbans / jpush example snippets




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

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

...

$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;
}
bash
$ cp examples/config.php.example examples/config.php
 bash
# 假定当前目录为 JPush 源码所在的根目录
$ php examples/push_example.php
bash
# 编辑 tests/bootstrap.php 文件,填入必须的变量值
# OR 设置相应的环境变量

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

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