-
-
Save miznokruge/01b8d43f48ba6adf2adc6dbccfeb308e to your computer and use it in GitHub Desktop.
Send SMS using AWS SNS via AWS PHP SDK
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Aws\Sns\SnsClient; | |
$sns = \Aws\Sns\SnsClient::factory(array( | |
'credentials' => [ | |
'key' => '<access_key>', | |
'secret' => '<access_secret>', | |
], | |
'region' => '<region>', | |
'version' => 'latest', | |
)); | |
$result = $sns->publish([ | |
'Message' => '<message>', // REQUIRED | |
'MessageAttributes' => [ | |
'AWS.SNS.SMS.SenderID' => [ | |
'DataType' => 'String', // REQUIRED | |
'StringValue' => '<sender_id>' | |
], | |
'AWS.SNS.SMS.SMSType' => [ | |
'DataType' => 'String', // REQUIRED | |
'StringValue' => 'Transactional' // or 'Promotional' | |
] | |
], | |
'PhoneNumber' => '<phone_number>', | |
]); | |
print_r($result); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment