用nodejs連接aws短信發送服務發送驗證碼,參考連接https://gist.github.com/tmarshall/6149ed2475f964cda3f5
不過這里代碼的問題是需要ARN(Amazon Resource Names)參數 ,ARN又分為 Topic ARN(訂閱相關)和Target ARN(告警相關),瞬間蒙蔽了。這是啥?
然后問了下前輩。果然不用這些就可以。so easy
const AWS = require('aws-sdk'); AWS.config.update({ accessKeyId: amazonKey, secretAccessKey: amazonSecret, region: 'us-east-1'//自己看下aws配置 }); const sns = new AWS.SNS(); const params = { Message: '驗證碼123456', PhoneNumber: '8618888888888' } sns.publish(params, function(err, data) { if (err){ // an error occurred console.log(err, err.stack); } else { // successful response } })