@@ -34,6 +34,7 @@ require 'vendor/autoload.php';
3434
3535use Pushbots\PushbotsClient;
3636use GuzzleHttp\Exception\ClientException;
37+ use GuzzleHttp\Exception\ServerException;
3738use GuzzleHttp\Psr7;
3839
3940$client = new PushbotsClient("APPLICATION_ID", "APPLICATION_SECRET");
6162} catch (ClientException $e) {
6263 echo Psr7\str($e->getRequest());
6364 echo Psr7\str($e->getResponse());
65+ } catch (ServerException $e) {
66+ echo Psr7\str($e->getRequest());
67+ echo Psr7\str($e->getResponse());
6468}
6569
6670```
@@ -92,30 +96,48 @@ Sending to one device [Transactional]
9296
9397``` php
9498use GuzzleHttp\Exception\ClientException;
99+ use GuzzleHttp\Exception\ServerException;
95100use GuzzleHttp\Psr7;
96101......
97- //Sample sending campaign to an alias
98102try {
99103 $client->transactional->send([
100- // iOS and Android only supported
104+ //topic [Required] of the transactional notification [can be any value, used only for tracking]
105+ "topic" => "welcome_campaign",
106+ //Platform [Required]
101107 //0 => iOS
102108 //1 => Android
103- "platform" => 0,
104- //token
105- "token" => "343aa292e2bb642db2abb24124417cdf945a03e18c9434499d0dcef8b0d7dd0f",
106- //Message
107- "msg" => "Notification message"
109+ //2 => Chrome
110+ //3 => Firefox
111+ //4 => Opera
112+ //5=> Safari
113+ "platform" => 0,
114+ //recipients [Required]
115+ "recipients ["=> [
116+ "tokens"=> ["343aa292e2bb642db2abb24124417cdf945a03e18c9434499d0dcef8b0d7dd0f"]
117+ //==OR== "ids"=>["ID"]
118+ ],
119+ //Message [Required]
120+ "message" => [
121+ "title"=>"title", //[Optional]
122+ "body" => "Notification message",
123+ "payload" => ["key"=>"value"] //[Optional]
124+ ]
108125 ]);
109126} catch (ClientException $e) {
110127 echo Psr7\str($e->getRequest());
111128 echo Psr7\str($e->getResponse());
129+ } catch (ServerException $e) {
130+ echo Psr7\str($e->getRequest());
131+ echo Psr7\str($e->getResponse());
112132}
113133```
114134
115135Changelog
116136-------------
117137Version 1.2.0
118-
138+ * Bug fixes.
139+ * Add transactional API support v3.
140+ * Catch GuzzleExceptions in sample code.
119141
120142Version 1.1.0
121143 * Add testing notification.
0 commit comments