【发布时间】:2021-03-25 15:09:55
【问题描述】:
大家好,我正在尝试通过 nodejs 使用免费电话号码通过亚马逊 pinpoint 发送 SMS 消息。请注意,为了安全起见,此代码中的数字已更改。这是我的代码:
router.get("/send-text", async (req, res, next) => {
try {
const sender = "+18446850251";
const destinationNumber = "+14325948991";
const message = "HELLO from AWS";
const applicationId = "myApplicationId";
const messageType = "TRANSACTIONAL";
AWS.config.update({ region: "us-east-1" });
const pinpoint = new AWS.Pinpoint();
const params = {
ApplicationId: applicationId,
MessageRequest: {
Addresses: {
[destinationNumber]: {
BodyOverride: message,
ChannelType: "SMS"
}
},
MessageConfiguration: {
SMSMessage: {
Body: message,
MessageType: messageType,
OriginationNumber: sender
}
}
}
};
const result = await pinpoint.sendMessages(params).promise();
res.send(result);
} catch (error) {
console.log(error);
next(error);
}
});
运行此代码后,我得到以下响应:
{
MessageResponse: {
ApplicationId: "myApplicationId",
RequestId: "8beaebf0-f33a-42d3-bb88-1f3efcf493eb",
Result: {
+14325948991: {
DeliveryStatus: "PERMANENT_FAILURE",
StatusCode: 404,
StatusMessage: "Resource not found"
}
}
}
}
旁注:我这样做的原因是我收到了来自 AWS 的电子邮件,我的理解是我不能再通过应用程序通过 SNS 主题向某人(10 位长代码)发送短信,并且必须从 6 月 1 日开始,使用 10DLC 长代码或免费号码通过精确定位发送它们,对吗?
【问题讨论】:
标签: amazon-web-services sms aws-pinpoint