【问题标题】:SenderID using Amazon Web Services PHP SDK使用 Amazon Web Services PHP SDK 的 SenderID
【发布时间】:2017-04-25 08:56:22
【问题描述】:

我正在尝试使用 AWS 开发工具包通过我的 PHP 站点发送 SMS。我使用来自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 的消息。所以我假设我的代码是错误的。

【问题讨论】:

    标签: php amazon-web-services sms


    【解决方案1】:

    我找到了解决方案。以这种方式设置参数。有效!

    $args = array(
        'MessageAttributes' => [
            'AWS.SNS.SMS.SenderID' => [
                   'DataType' => 'String',
                   'StringValue' => 'YourSenderName'
            ]
         ],
        "SMSType" => "Transactional",
        "PhoneNumber" => "+87654321",
        "Message" => "Hello World!"
    );
    

    【讨论】:

    • 您可以给我的答案投票...并将其设置为已解决。
    • 我已经给你投了赞成票,但由于我在这里的代表太低,它不会公开显示。我忘记将您的答案设置为解决方案,但我现在解决了。
    • 我欠你一条命
    • 它不适合我。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-12-11
    • 2014-08-08
    • 2018-01-18
    • 1970-01-01
    • 2011-08-02
    • 2015-06-08
    • 2011-01-15
    相关资源
    最近更新 更多