1.0.6 • Published 4 years ago

mns-node-sdk v1.0.6

Weekly downloads
7
License
MIT
Repository
github
Last release
4 years ago

mns-nodejs-sdk

Documents: http://doxmate.cool/aliyun/mns-nodejs-sdk/api.html

Installation

npm install mns-node-sdk

API Spec

See: https://help.aliyun.com/document_detail/27475.html

Usage

import { Client } from 'mns-node-sdk'

const client = new Client({
    accountId: '<account id>',
    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
    keepAlive: true,
    retries: 3,
  }
);

(async function () {
  let res;

  // create queue
  res = await client.createQueue({
    QueueName: '<queue name>'
  });
  console.log(res);
  
  // list queue
  res = await client.listQueue();
  console.log(JSON.stringify(res, null, 2));
  
  // create topic
  res = await client.createTopic({
    TopicName: '<topic name>'
  });
  console.log(res);
  
  // get topic attributes
  res = await client.getTopicAttributes({
    TopicName: '<topic name>'
  });
  console.log(res);
  
  // publish message
  res = await client.publishMessage({
    TopicName: '<topic name>',
    Payloads: {
      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

1.0.6

4 years ago

1.0.6-alpha.3

4 years ago

1.0.6-alpha.2

4 years ago

1.0.6-alpha.1

4 years ago

1.0.6-alpha

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.2-alpha

4 years ago

1.0.1-alpha

4 years ago

1.0.0

4 years ago

0.9.9

4 years ago

0.9.0

4 years ago