Skip to content

Instantly share code, notes, and snippets.

@ankitsam
Created May 1, 2017 08:25
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save ankitsam/24b6895d50a8ed510fa414cc71b17616 to your computer and use it in GitHub Desktop.
Save ankitsam/24b6895d50a8ed510fa414cc71b17616 to your computer and use it in GitHub Desktop.
Send SMS using AWS SNS via AWS PHP SDK
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