Skip to content

Instantly share code, notes, and snippets.

@abelcallejo
Last active May 9, 2019 01:12
Show Gist options
  • Save abelcallejo/f8e165191ef77c694fd010d6c65e434e to your computer and use it in GitHub Desktop.
Save abelcallejo/f8e165191ef77c694fd010d6c65e434e to your computer and use it in GitHub Desktop.
Sending an SMS message with PHP and Amazon SNS

Sending SMS message using PHP and Amazon SNS

php aws

Instructions

On the command-line, use composer to get the AWS SDK for PHP

composer require aws/aws-sdk-php

Then test it by using the sns.php file

References

StackOverflow,Sending SMS with Amazon AWS services PHP

require './vendor/autoload.php';
error_reporting(E_ALL);
ini_set("display_errors", 1);
$params = array(
'credentials' => array(
'key' => 'YOUR_KEY_HERE',
'secret' => 'YOUR_SECRET_HERE',
),
'region' => 'ap-southeast-1', // < your aws from SNS Topic region
'version' => 'latest'
);
$sns = new \Aws\Sns\SnsClient($params);
$args = array(
"SenderID" => "SenderName",
"SMSType" => "Transactional",
"Message" => "Hello World!",
"PhoneNumber" => "FULL_PHONE_NUMBER" // +cc#######
);
$result = $sns->publish($args);
echo "<pre>";
var_dump($result);
echo "</pre>";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment