[英]AWS: SNS sending SMS message to multiple phone numbers
我想通過我的移動應用將以下消息發送到多個電話號碼:
“ John Doe邀請您參加會議。下載會議材料http://alink.com ”
此消息將是Transactional
我有一個在EC2上運行的Node.js。 我是移動應用程序開發人員,並且是AWS的新手。
在我的SNS控制台中,我創建了一個主題。 這創建了一個ARN: arn:aws:sns:us-east-1:xxx1234xxxx:MyAppName
我在NodeJS中有以下代碼:
var AWS = require('aws-sdk');
var auth = require('../snsAuth');
AWS.config.update = auth
var sns = new AWS.SNS();
var params = {
Message: "John Doe invited you to a meeting. Download meeting material http://alink.com",
MessageStructure: 'string',
PhoneNumber: '1xxx1234',
Subject: 'MyApp'
};
sns.setSMSAttributes(
{
attributes: {
DefaultSMSType: "Transactional"
}
},
function (error) {
if (error) {
console.log(error);
}
}
);
sns.publish(params, function (err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
});
我不知道如何發送多個電話號碼作為參數。 根據文檔,看來我需要先預訂一個主題,然后再發布該主題。 如果這些步驟正確,我該如何在代碼中執行呢?
您可以使用訂閱API通過短信向主題訂閱電話號碼。 但是用戶必須先確認對主題的訂閱,然后才能獲得任何已發布的事件。
var params = {
Protocol: 'sms',
TopicArn: 'arn:aws:sns:us-east-1:xxx1234xxxx:MyAppName',
Endpoint: '1xxx1234'
};
sns.subscribe(params, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.