Skip to content

Instantly share code, notes, and snippets.

@olotintemitope
Forked from ankitsam/sms.php
Created September 11, 2022 18:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save olotintemitope/a775ddf932236623c9579905eec602ac to your computer and use it in GitHub Desktop.
Save olotintemitope/a775ddf932236623c9579905eec602ac 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);
@olotintemitope
Copy link
Author

AWS SNS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment