|
15 | 15 | $spilt = ' - '; |
16 | 16 |
|
17 | 17 |
|
18 | | - |
19 | | - |
20 | 18 | $master_secret = 'd94f733358cca97b18b2cb98'; |
21 | 19 | $app_key='47a3ddda34b2602fa9e17c01'; |
22 | 20 | JPushLog::setLogHandlers(array(new StreamHandler('jpush.log', Logger::DEBUG))); |
|
52 | 50 |
|
53 | 51 | echo $br . '-------------' . $br; |
54 | 52 |
|
| 53 | +//easy push with ios badge +1 |
| 54 | +try { |
| 55 | + $result = $client->push() |
| 56 | + ->setPlatform(M\all) |
| 57 | + ->setAudience(M\all) |
| 58 | + ->setNotification(M\notification('Hi, JPush', M\ios("Hi, IOS", "happy", "+1"))) |
| 59 | + ->printJSON() |
| 60 | + ->send(); |
| 61 | + echo 'Push Success.' . $br; |
| 62 | + echo 'sendno : ' . $result->sendno . $br; |
| 63 | + echo 'msg_id : ' .$result->msg_id . $br; |
| 64 | + echo 'Response JSON : ' . $result->json . $br; |
| 65 | +} catch (APIRequestException $e) { |
| 66 | + echo 'Push Fail.' . $br; |
| 67 | + echo 'Http Code : ' . $e->httpCode . $br; |
| 68 | + echo 'code : ' . $e->code . $br; |
| 69 | + echo 'Error Message : ' . $e->message . $br; |
| 70 | + echo 'Response JSON : ' . $e->json . $br; |
| 71 | + echo 'rateLimitLimit : ' . $e->rateLimitLimit . $br; |
| 72 | + echo 'rateLimitRemaining : ' . $e->rateLimitRemaining . $br; |
| 73 | + echo 'rateLimitReset : ' . $e->rateLimitReset . $br; |
| 74 | +} catch (APIConnectionException $e) { |
| 75 | + echo 'Push Fail: ' . $br; |
| 76 | + echo 'Error Message: ' . $e->getMessage() . $br; |
| 77 | + //response timeout means your request has probably be received by JPUsh Server,please check that whether need to be pushed again. |
| 78 | + echo 'IsResponseTimeout: ' . $e->isResponseTimeout . $br; |
| 79 | +} |
| 80 | + |
| 81 | +echo $br . '-------------' . $br; |
| 82 | + |
55 | 83 |
|
56 | 84 | //full push |
57 | 85 | try { |
|
0 commit comments