Har*_*iya 5 php amazon-web-services amazon-sns web
我正在尝试学习 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);
Run Code Online (Sandbox Code Playgroud)
我想直接在号码上发送短信。这段代码给出了这个错误
致命错误:未捕获的异常“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 InvalidParameter Invalid parameter: PhoneNumber Reason: +1234567890 is not valid to publish to 13e181c2-a20f-5e77-9c8e-d38c55c50266 ' exception 'GuzzleHttp\Exception\ClientException' with message 'Client error: POST https://sns.ap-south-1.amazonaws.com resulted in a 400 Bad Request
我不知道为什么....
| 归档时间: |
|
| 查看次数: |
1471 次 |
| 最近记录: |