Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'SenderID' issues sending SMS on Amazon SNS (Official PHP SDK)

For some reason the SenderID seems to revert to NOTICE - see here Amazon SNS - SMS Notice when I set the SenderID in the code.

When I leave the SenderID variable out, it sends as the default set - this is good, but we will be occasionally changing the name for different uses.

I am using the Official PHP SDK, with the code below:

$aws_cred = array(
    'credentials' => array(
        'key' => 'GOT THE KEY',
        'secret' => 'GOT THE SECRET',
    ),
    'region' => 'eu-west-1', // < your aws from SNS Topic region
    'version' => 'latest'
    );
    $sns = new \Aws\Sns\SnsClient($aws_cred);

    $args = array(
    "SenderID" => "MySendID",
    "SMSType" => "Promotional",
    "Message" => "Amazon y u do dis??",
    "PhoneNumber" => "+number"
    );

    $result = $sns->publish($args);

I am sending to the UK (so SID works there), and also it is within the 11 character limit.

Does anyone have any idea why this is happening?

Cheers

like image 494
XLR Avatar asked Oct 17 '22 10:10

XLR


1 Answers

I have found the answer.

The search system didn't materialise this originally, but finally, I have found it.

QUOTE FROM: https://stackoverflow.com/a/43748448/7586984

I found the solution. Set the args this way. It works!

$args = array(
    'MessageAttributes' => [
          'AWS.SNS.SMS.SenderID' => [
               'DataType' => 'String',
               'StringValue' => 'YourSenderName'
        ]
     ],
      "SMSType" => "Transactional",
      "PhoneNumber" => "+87654321",
      "Message" => "Hello World!"
);
like image 137
XLR Avatar answered Oct 21 '22 07:10

XLR