Skip to content

Commit a9eabc3

Browse files
committed
Add transactional API v3 support && Bump to 1.2.0
1 parent e78345b commit a9eabc3

File tree

2 files changed

+31
-9
lines changed

2 files changed

+31
-9
lines changed

README.md

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ require 'vendor/autoload.php';
3434

3535
use Pushbots\PushbotsClient;
3636
use GuzzleHttp\Exception\ClientException;
37+
use GuzzleHttp\Exception\ServerException;
3738
use GuzzleHttp\Psr7;
3839

3940
$client = new PushbotsClient("APPLICATION_ID", "APPLICATION_SECRET");
@@ -61,6 +62,9 @@ try {
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
9498
use GuzzleHttp\Exception\ClientException;
99+
use GuzzleHttp\Exception\ServerException;
95100
use GuzzleHttp\Psr7;
96101
......
97-
//Sample sending campaign to an alias
98102
try {
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

115135
Changelog
116136
-------------
117137
Version 1.2.0
118-
138+
* Bug fixes.
139+
* Add transactional API support v3.
140+
* Catch GuzzleExceptions in sample code.
119141

120142
Version 1.1.0
121143
* Add testing notification.

src/PushbotsTransactional.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ public function __construct($client)
2929
*/
3030
public function send($options)
3131
{
32-
return $this->_client->post("push/one", $options);
32+
return $this->_client->post("3/push/transactional", $options);
3333
}
3434
}

0 commit comments

Comments
 (0)