mns-nodejs-sdk
Documents: http://doxmate.cool/aliyun/mns-nodejs-sdk/api.html
该 SDK 并未完全实现所有文档所提及的功能,如果您想使用的功能并未实现,请提issue以增加优先级。
Installation
npm install @alicloud/mns --save
API Spec
See: https://help.aliyun.com/document_detail/27475.html
Test
ACCOUNT_ID=<ACCOUNT_ID> ACCESS_KEY_ID=<ACCESS_KEY_ID> ACCESS_KEY_SECRET=<ACCESS_KEY_SECRET> make test
Installation
You can install it via npm/cnpm/yarn.
$ npm install @alicloud/mns --save
Usage
const MNSClient = require('@alicloud/mns');
const accountid = '<account id>';
var client = new MNSClient(accountid, {
region: '<region>',
accessKeyId: '<access key id>',
accessKeySecret: '<access key secret>',
secure: false,
internal: false,
vpc: false
});
(async function () {
let res;
res = await client.createQueue('test-queue2');
console.log(res);
res = await client.listQueue();
console.log(JSON.stringify(res, null, 2));
res = await client.createTopic('test-topic');
console.log(res);
res = await client.getTopicAttributes('test-topic');
console.log(res);
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);
});
License
The MIT License