The Publish action sends a message to all of a topic’s subscribed endpoints. When a messageId is returned, the message has been saved and Amazon SNS will attempt to deliver it to the topic’s subscribers shortly. The format of the outgoing message to each subscribed endpoint depends on the notification protocol selected.
Access
public
Parameters
Parameter |
Type |
Required |
Description |
---|---|---|---|
|
Required |
The topic you want to publish to. |
|
|
Required |
The message you want to send to the topic. Constraints: Messages must be UTF-8 encoded strings at most 8 KB in size (8192 bytes, not 8192 characters). |
|
|
Optional |
An associative array of parameters that can have the following keys:
|
Returns
Type |
Description |
---|---|
A |
Examples
Publish a message to the topic.
$sns = new AmazonSNS(); // Get topic attributes $response = $sns->publish( 'arn:aws:sns:us-east-1:9876543210:example-topic', 'This is my very first message to the world!', array( 'Subject' => 'Hello world!' ) ); // Success? var_dump($response->isOK());Result:
bool(true)
Related Methods
Source
Method defined in services/sns.class.php | Toggle source view (8 lines) | View on GitHub