mns-nodejs-sdk (英语)
联合国 http://doxmate.cool/aliyun/mns-nodejs-sdk/api.html (中文(简体) )
(原始内容存档于2018-03-26) (英语). SDK SDK QQ, QQ, QQ, QQ问题以增加优先级。
安装
npm install @alicloud/mns --save
API 光谱
见: https://help.aliyun.com/document detail/27475.html 页面存档备份,存于互联网档案馆
测试
ACCOUNT_ID=<ACCOUNT_ID> ACCESS_KEY_ID=<ACCESS_KEY_ID> ACCESS_KEY_SECRET=<ACCESS_KEY_SECRET> make test
安装
你可以通过npm/cnpm/yarn安装.
$ npm install @alicloud/mns --save
使用量
const MNSClient = require('@alicloud/mns');
const accountid = '<account id>';
var client = new MNSClient(accountid, {
region: '<region>',
accessKeyId: '<access key id>',
accessKeySecret: '<access key secret>',
// optional & default
secure: false, // use https or http
internal: false, // use internal endpoint
vpc: false // use vpc endpoint
});
(async function () {
let res;
// create queue
res = await client.createQueue('test-queue2');
console.log(res);
// list queue
res = await client.listQueue();
console.log(JSON.stringify(res, null, 2));
// create topic
res = await client.createTopic('test-topic');
console.log(res);
// get topic attributes
res = await client.getTopicAttributes('test-topic');
console.log(res);
// publish message
res = await client.publishMessage('<topic name>', {
MessageBody: 'content',
MessageAttributes: {
DirectSMS: JSON.stringify({
FreeSignName: '',
TemplateCode: '<template code>',
Type: '<type>',
Receiver: '<phone number>',
SmsParams: JSON.stringify({
code: '<code>',
product: '<product>'
})
})
}
});
console.log(res);
})().then((data) => {
console.log(data);
}, (err) => {
console.log(err.stack);
});
许可证
这个 麻省理工学院 许可证