gpt4 book ai didi

php - AWS SNS 参数电话号码无效

转载 作者:可可西里 更新时间:2023-10-31 23:45:04 27 4
gpt4 key购买 nike

我正在尝试学习 aws sns 服务以从我的 Web 应用程序发送短信。我在本地主机上工作。

$params = array(
'credentials' => array(
'key' => 'iam_key',
'secret' => 'iam_secret',
),
'region' => 'ap-south-1', // < your aws from SNS Topic region
'version' => 'latest',
'http' => ['verify'=>false]
);
$sns = \Aws\Sns\SnsClient::factory($params);

$msgattributes = [
'AWS.SNS.SMS.SenderID' => [
'DataType' => 'String',
'StringValue' => 'Klassroom',
],
'AWS.SNS.SMS.SMSType' => [
'DataType' => 'String',
'StringValue' => 'Transactional',
]
];

$payload = array(
'Message' => "HK test",
"PhoneNumber" => "1234567890",
'MessageAttributes' => $msgattributes
);

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

我想直接在号码上发送短信。此代码给出此错误

fatal error :未捕获异常“Aws\Sns\Exception\SnsException”,消息为“在“https://sns.ap-south-1.amazonaws.com”上执行“发布”时出错; AWS HTTP 错误:客户端错误:POST https://sns.ap-south-1.amazonaws.com 导致 400 Bad Request 响应:发件人 InvalidPara (truncated...) InvalidParameter (client): Invalid parameter: PhoneNumber Reason: +1234567890 is not valid to publish to - Sender <code>InvalidParameter</code> Invalid parameter: PhoneNumber Reason: +1234567890 is not valid to publish to 13e181c2-a20f-5e77-9c8e-d38c55c50266 ' exception 'GuzzleHttp\Exception\ClientException' with message 'Client error: <code>POST https://sns.ap-south-1.amazonaws.com</code> resulted in a 400 Bad Request

我不知道为什么....

最佳答案

我认为 AWS 的电话号码必须包含国家代码。

例如,如果我的电话号码是 (999) 365-6721,它将是 +19993656721(美国)

关于php - AWS SNS 参数电话号码无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46568343/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com