获得AWS SNS的成功响应,但未送达SMS

我正在写一个简单的程序来使用Javascript客户端使用SNS服务发送短信。

var AWS = require('aws-sdk'); var sns = new AWS.SNS({ region : 'ap-southeast-1', accessKeyId: '', secretAccessKey: '' }); sns.publish({ Message : "Test message", PhoneNumber : "Test number" }, function (err, data) { if(err) { console.log("Error - " + err); } else { console.log('Success - '); console.log(data); } }); 

我获得了成功,数据看起来像

 { ResponseMetadata: { RequestId: '3b4e8c82-976c-55da-b1fa-dcd9ddc7254d' }, MessageId: '47a38cbe-2047-5056-a615-dce56aecc0c1' } 

但是,短信不会被发送。

可能是什么问题呢?

消息在24日之后开始交付新的请求。 度量标准仪表板显示的数据每天陈旧。 在仪表板上它正确地显示所有短信交付都在9月21日失败,尽pipeAPI的积极响应。 这使我重新考虑使用SNS进行短信的决定。

感谢所有帮助。

我们需要指定更多的SNS参数。

文档页面可能有所帮助:

  • 推送到SNS: http : //docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SNS.html#publish-property

试试这个代码

 var AWS = require('aws-sdk'); var sns = new AWS.SNS({ region: 'ap-southeast-1', accessKeyId: '', secretAccessKey: '' }); var params = { Message: 'Test message', MessageStructure: 'string', PhoneNumber: 'Test number' }; sns.publish(params, function (err, data) { if (err) console.log("error-> " + err + "-" + number + "-" + JSON.stringify(params)); // an error occurred else console.log("SMS to " + number + " successfull " + JSON.stringify(data)); // successful response }); 

你有这样的输出

 {"ResponseMetadata":"RequestId":"2bb91f08-3ef0-5e55-8219-4645645"},"MessageId":"943a1224-042c-576c-936e-sfsdf34535"} {"Message":"hai manaf...ru happy","MessageStructure":"string","PhoneNumber":"+9197********"}. 

但是我没有收到短信给我的免打扰电话号码。 我仍然研究这个问题。

你的aws-sdk版本是什么? 尝试更新最新的一个。