Skip to content

Commit af15d60

Browse files
committed
Merge pull request #6 from vis4573/master
New API methods createPlatformEndpoint, deleteEndpoint
2 parents 9ed3274 + 75e8594 commit af15d60

File tree

3 files changed

+59
-0
lines changed

3 files changed

+59
-0
lines changed

.project

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>AmazonSNS-PHP-API</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
</buildSpec>
9+
<natures>
10+
</natures>
11+
</projectDescription>

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ Available methods:
6161
* `setTopicAttributes($topicArn, $attrName, $attrValue)`
6262
* `subscribe($topicArn, $protocol, $endpoint)`
6363
* `unsubscribe($subscriptionArn)`
64+
* `createPlatformEndpoint($platformapplicationarn, $token, $userdata)`
65+
* `deleteEndpoint($devicearn)`
6466

6567
To set the API region (us-east-1, us-west-2, us-west-1, eu-west-1, etc):
6668

lib/AmazonSNS.php

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,53 @@ public function unsubscribe($subscriptionArn) {
420420
return true;
421421
}
422422

423+
/**
424+
* Create Platform endpoint
425+
*
426+
* @link http://docs.aws.amazon.com/sns/latest/api/API_CreatePlatformEndpoint.html
427+
* @param string $platformapplicationarn
428+
* @param string $token
429+
* @param string $userdata
430+
* @return bool
431+
* @throws InvalidArgumentException
432+
*/
433+
public function createPlatformEndpoint($platformapplicationarn, $token, $userdata) {
434+
if(empty($platformapplicationarn) || empty($token) || empty($userdata)) {
435+
throw new InvalidArgumentException('Must supply a Platformapplicationarn,Token & Userdata to create platform endpoint');
436+
}
437+
438+
$response= $this->_request('CreatePlatformEndpoint', array(
439+
'PlatformApplicationArn' => $platformapplicationarn,
440+
'Token' => $token,
441+
'CustomUserData' => $userdata
442+
));
443+
444+
return strval($response->CreatePlatformEndpointResult->EndpointArn);
445+
}
446+
447+
/*
448+
* Delete endpoint
449+
*
450+
* @link http://docs.aws.amazon.com/sns/latest/api/API_DeleteEndpoint.html
451+
* @param string $devicearn
452+
453+
* @return bool
454+
* @throws InvalidArgumentException
455+
*/
456+
public function deleteEndpoint($devicearn) {
457+
if(empty($devicearn)) {
458+
throw new InvalidArgumentException('Must supply a DeviceARN to remove platform endpoint');
459+
}
423460

461+
$response= $this->_request('DeleteEndpoint', array(
462+
'EndpointArn' => $devicearn,
463+
464+
));
465+
466+
return true;
467+
}
468+
469+
424470
//
425471
// Private functions
426472
//

0 commit comments

Comments
 (0)