我想了解aws sns服務從我的web應用程序發送短信。 我在本地主機上工作。AWS SNS無效的參數電話號碼
$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);
我想直接在號碼上發送短信。這段代碼給出了這個錯誤
致命錯誤:未知的異常'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
無效參數:PhoneNumber原因:+1234567890無法發佈到13e181c2-a20f-5e77-9c8e-d38c55c50266'帶有消息的'GuzzleHttp \ Exception \ ClientException'異常「客戶端的錯誤:POST https://sns.ap-south-1.amazonaws.com
產生了一個400錯誤的請求
我不知道爲什麼....
我猜想,電話號碼,首先必須註冊爲SNS通知。 – ceejayoz
我們不能使用aws sns服務直接在號碼上發送短信嗎? –