Skip to content

Commit 9ed3274

Browse files
committed
Merge branch 'rohit-wadhwa-patch-1'
2 parents 953504c + 6c83dcc commit 9ed3274

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ Available methods:
5656
* `listSubscriptions()`
5757
* `listSubscriptionsByTopic($topicArn)`
5858
* `listTopics()`
59-
* `publish($topicArn, $message)`
59+
* `publish($topicArn, $message, $subject, $messageStructure)`
6060
* `removePermission($topicArn, $label)`
6161
* `setTopicAttributes($topicArn, $attrName, $attrValue)`
6262
* `subscribe($topicArn, $protocol, $endpoint)`

lib/AmazonSNS.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,10 +308,11 @@ public function listTopics($nextToken = null) {
308308
* @param string $topicArn
309309
* @param string $message
310310
* @param string $subject [optional] Used when sending emails
311+
* @param string $messageStructure [optional] Used when you want to send a different message for each protocol.If you set MessageStructure to json, the value of the Message parameter must: be a syntactically valid JSON object; and contain at least a top-level JSON key of "default" with a value that is a string.
311312
* @return string
312313
* @throws InvalidArgumentException
313314
*/
314-
public function publish($topicArn, $message, $subject = '') {
315+
public function publish($topicArn, $message, $subject = '', $messageStructure = '') {
315316
if(empty($topicArn) || empty($message)) {
316317
throw new InvalidArgumentException('Must supply a TopicARN and Message to publish to a topic');
317318
}
@@ -325,6 +326,10 @@ public function publish($topicArn, $message, $subject = '') {
325326
$params['Subject'] = $subject;
326327
}
327328

329+
if(!empty($messageStructure)) {
330+
$params['MessageStructure'] = $messageStructure;
331+
}
332+
328333
$resultXml = $this->_request('Publish', $params);
329334

330335
return strval($resultXml->PublishResult->MessageId);

0 commit comments

Comments
 (0)