关于nodejs调用亚马逊aws短信发送服务

用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
    }
})