30Jun/163
Send SMS using AWS SNS
Usually I go with Twillio for sending SMS but AWS has a cheaper and easier solution for this.
Here is the code to send a sms using AWS SNS
First thing install aws/aws-sdk-php package
require __DIR__.'/../vendor/autoload.php';
use Aws\Sns\SnsClient;
$client = SnsClient::factory([ 'credentials' => [ 'key' => 'your key', 'secret' => 'your secret', ], 'region' => 'us-west-2', 'version' => "latest" ]); $sent = $client->publish( [ 'Message' => 'This is the message', 'PhoneNumber' => '+123344545', 'MessageAttributes' => [ 'AWS.SNS.SMS.SenderID' => [ 'DataType' => 'String', 'StringValue' => 'The sender' ] ] ] );
November 18th, 2016 - 07:12
I use this code. If i call publish with ‘PhoneNumber’ , I get the AWS Error Message Invalid Parameter: Topic Arn or TargetArn Reason : no value for required paramter.
But if i use a topicArn with my mobile phone number subscribed to this topic , I’m able to send SMS messages.
You think I’m missing something.
- Deepak
February 9th, 2017 - 02:45
same problem here, with PhoneNumber I have the error InvalidParameter (client): Invalid parameter: PhoneNumber Reason: +15255xxxxxxxx is not valid to publish to –
June 18th, 2017 - 17:27
When using it. I got the error SnsClient class not found. I am using codeigniter for it.