在 lambda 中通过 SNS 发送短信时未收到短信
当在lambda函数中,我的代码是此的
const otp = generateOTP();
const message = `Your XXXX Verification Code is ${otp} .`;
var params = {
Message: message,
PhoneNumber: "+91xxxxxxxxxx",
};
AWS.config.update({region: 'ap-south-1'});
var publishTextPromise = new AWS.SNS({apiVersion: '2022-04-01'}).publish(params).promise();
return new Promise((resolve, reject) => {
publishTextPromise.then((data) => {
console.log("MessageID is " + data.MessageId);
const response = {
statusCode: 200,
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify(data)
};
console.log('Server response function');
resolve(response);
}).catch((error) => { reject(Error(error)); });
});
在调用此lambda功能时会得到此响应
Server response function
{
"statusCode": 200,
"headers": {
"Content-Type": "application/json"
},
"body": {
"ResponseMetadata": {
"RequestId": "29796d67-f32e-5e42-a761-37a72809164d"
},
"MessageId": "2f8ffee0-7e0d-5cd3-a5b0-a420a52a14dc"
}
}
,我 我将在控制台中得到解决的响应,这意味着SMS已发送,但我没有收到它。 我必须在AWS SNS Mobile中配置SNS手册吗?文字消息或其他? 还是他们发送验证OTP的其他方法?
I am sending the OTP using AWS SNS service when in a lambda function my code is this
const otp = generateOTP();
const message = `Your XXXX Verification Code is ${otp} .`;
var params = {
Message: message,
PhoneNumber: "+91xxxxxxxxxx",
};
AWS.config.update({region: 'ap-south-1'});
var publishTextPromise = new AWS.SNS({apiVersion: '2022-04-01'}).publish(params).promise();
return new Promise((resolve, reject) => {
publishTextPromise.then((data) => {
console.log("MessageID is " + data.MessageId);
const response = {
statusCode: 200,
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify(data)
};
console.log('Server response function');
resolve(response);
}).catch((error) => { reject(Error(error)); });
});
and i am getting this response when invoking this lambda function
Server response function
{
"statusCode": 200,
"headers": {
"Content-Type": "application/json"
},
"body": {
"ResponseMetadata": {
"RequestId": "29796d67-f32e-5e42-a761-37a72809164d"
},
"MessageId": "2f8ffee0-7e0d-5cd3-a5b0-a420a52a14dc"
}
}
But I am not receiving the SMS on that number I don't know what is the problem here cause the I am getting resolved response in the console which means the SMS is send but I am not received it.
Do I have to config the sns manual in aws sns mobile -> text messaging or something??
or is their any other way to send verification otp ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论