zone_examples.php 667 B

123456789101112131415161718192021222324
  1. <?php
  2. // 这只是使用样例,不应该直接用于实际生产环境中 !!
  3. require 'config.php';
  4. use JPush\Client as JPush;
  5. // 简单推送示例
  6. // 这只是使用样例,不应该直接用于实际生产环境中 !!
  7. $client = new JPush($app_key, $master_secret, null, null, 'BJ');
  8. $push_payload = $client->push()
  9. ->setPlatform('all')
  10. ->addAllAudience()
  11. ->setNotificationAlert('Hi, JPush');
  12. try {
  13. $response = $push_payload->send();
  14. print_r($response);
  15. } catch (\JPush\Exceptions\APIConnectionException $e) {
  16. // try something here
  17. print $e;
  18. } catch (\JPush\Exceptions\APIRequestException $e) {
  19. // try something here
  20. print $e;
  21. }