grouppush_example.php 580 B

123456789101112131415161718192021222324
  1. <?php
  2. require __DIR__ . '/../autoload.php';
  3. use JPush\Client as JPush;
  4. $group_key = 'xxxx';
  5. $group_master_secret = 'xxxx';
  6. $client = new JPush('group-' . $group_key, $group_master_secret, null);
  7. $push_payload = $client->push()
  8. ->setPlatform('all')
  9. ->addAllAudience()
  10. ->setNotificationAlert('Hi, JPush');
  11. try {
  12. $response = $push_payload->send();
  13. print_r($response);
  14. } catch (\JPush\Exceptions\APIConnectionException $e) {
  15. // try something here
  16. print $e;
  17. } catch (\JPush\Exceptions\APIRequestException $e) {
  18. // try something here
  19. print $e;
  20. }