Skip to content

Commit c2a78dd

Browse files
committed
Fix typo in docs, catch Client errors and print it 🐞
1 parent 0a31995 commit c2a78dd

File tree

1 file changed

+26
-18
lines changed

1 file changed

+26
-18
lines changed

README.md

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,27 +33,35 @@ Example
3333
require 'vendor/autoload.php';
3434

3535
use Pushbots\PushbotsClient;
36+
use GuzzleHttp\Exception\ClientException;
37+
use GuzzleHttp\Psr7;
3638

3739
$client = new PushbotsClient("APPLICATION_ID", "APPLICATION_SECRET");
3840

39-
//Sample sending campaign to all users
40-
$client->campaign->send([
41-
//Platforms
42-
//0 => iOS
43-
//1 => Android
44-
//2 => Chrome
45-
//3 => Firefox
46-
//4 => Safari
47-
"platform" => [0,1,2,3,4],
48-
//Message
49-
"msg" => "Notification message",
50-
//Badge [iOS only]
51-
"badge" => "+1",
52-
//Notification payload
53-
"payload"=>[
54-
"key"=> "value"
55-
]
56-
]);
41+
try {
42+
//Sample sending campaign to all users
43+
$res = $client->campaign->send([
44+
//Platforms
45+
//0 => iOS
46+
//1 => Android
47+
//2 => Chrome
48+
//3 => Firefox
49+
//4 => Opera
50+
//5=> Safari
51+
"platform" => [0,1,2,3,4,5],
52+
//Message
53+
"msg" => "Notification message",
54+
//Badge [iOS only]
55+
"badge" => "+1",
56+
//Notification payload
57+
"payload"=>[
58+
"key"=> "value"
59+
]
60+
]);
61+
} catch (ClientException $e) {
62+
echo Psr7\str($e->getRequest());
63+
echo Psr7\str($e->getResponse());
64+
}
5765

5866
```
5967

0 commit comments

Comments
 (0)