I am trying to send a sms to a particular number using aws sns using the following code but it requires a target/topic arn which is not applicable for me as I want to send sms to the numbers that I set in the params.
$client = SnsClient::factory([
'credentials' => [
'key' => "my key",
'secret' => "my secret"
],
'region' => "us-east-1",
'version' => "latest"
]);
$sent = $client->publish(
[
'Message' => 'This is the message',
'PhoneNumber' => '+91887******7'
]
);
I am not able to find the exact params for the publish object.
I had to update the aws php sdk (1). Then the following code works fine -
$sns = SnsClient::factory(array(
'credentials' => array(
'key' => 's3_key',
'secret' => 's3_secret'
),
'region' => Constants::$s3Region,
'version' => 'latest'
));
$msgattributes = [
'AWS.SNS.SMS.SenderID' => [
'DataType' => 'String',
'StringValue' => 'Klassroom',
],
'AWS.SNS.SMS.SMSType' => [
'DataType' => 'String',
'StringValue' => 'Transactional',
]
];
$payload = array(
'Message' => $message,
'PhoneNumber' => $number,
'MessageAttributes' => $msgattributes
);
$result=$sns->publish($payload);