使用Amazon Web Services PHP SDK的SenderID [英] SenderID using Amazon Web Services PHP SDK
本文介绍了使用Amazon Web Services PHP SDK的SenderID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用AWS开发工具包通过我的PHP站点发送SMS.我使用的是通过Amazon AWS服务PHP发送短信的代码./p>
I'm trying to send an SMS through my PHP site using the AWS SDK. I use the code from Sending SMS with Amazon AWS services PHP.
require $_SERVER['DOCUMENT_ROOT'] . '/inc/aws/aws-autoloader.php';
error_reporting(E_ALL);
ini_set("display_errors", 1);
$params = array(
'credentials' => array(
'key' => 'abc',
'secret' => 'abc',
),
'region' => 'eu-west-1', // < your aws from SNS Topic region
'version' => 'latest'
);
$sns = new \Aws\Sns\SnsClient($params);
$args = array(
"SenderID" => "TestSender",
"SMSType" => "Transactional",
"Message" => "Sending SMS with PHP",
"PhoneNumber" => "+87654321"
);
$result = $sns->publish($args);
echo "<pre>";
var_dump($result);
echo "</pre>";
这不起作用.我已经使用许多不同的SenderID进行了测试,并且所有消息都是从NOTICE接收到的.但是,当我从AWS控制台发送消息时,会收到带有正确SenderID的消息.所以我认为我的代码是错误的.
This is not working. I have tested with a lot of different SenderIDs and all messages are received from NOTICE. However, when I send a message from the AWS console, the message is received with the correct SenderID. So I assume my code is wrong.
推荐答案
我找到了解决方案.这样设置参数.可行!
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!"
);
这篇关于使用Amazon Web Services PHP SDK的SenderID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文