egg-aliyun-sms

1.5.2 • Public • Published

egg-aliSMS

NPM version build status Test coverage David deps Known Vulnerabilities npm download

Install

$ npm i egg-aliyun-sms --save

Usage

// {app_root}/config/plugin.js
exports.aliSMS = {
  enable: true,
  package: 'egg-aliyun-sms',
};

Configuration

// {app_root}/config/config.default.js
 
exports.aliSMS = {
  client:{
    accessKeyId: 'yourAccessKeyId',
    secretAccessKey: 'yourAccessKeySecret',
    checkMobile: null, //check it work when this plugin init;
  }
};

see config/config.default.js for more detail.

see aliyun.com to get you accessKeyId and secretAccessKey

How to use

//you can use ctx and app
 
/**
 * send
 * */
this.ctx.aliSMS.sendSMS({
      PhoneNumbers: '1500000000',
      SignName: '云通信产品',
      TemplateCode: 'SMS_000000',
      TemplateParam: '{"code":"12345"}'
    }).then((res)=>{
      console.log(res)
    }).catch((err)=>{
      console.error(err)
    });
/**
 * query
 * */
this.ctx.aliSMS.queryDetail({
    PhoneNumber: '1500000000',
    SendDate: '20170731',
    PageSize: '10',
    CurrentPage: "1"
}).then(function (res) {
    let {Code, SmsSendDetailDTOs}=res
    if (Code === 'OK') {
        console.log(SmsSendDetailDTOs)
    }
}, function (err) {
    console.log(err)
})

More use here.

Example

Questions & Suggestions

Please open an issue here.

License

MIT

Package Sidebar

Install

npm i egg-aliyun-sms

Weekly Downloads

1

Version

1.5.2

License

MIT

Unpacked Size

9.2 kB

Total Files

9

Last publish

Collaborators

  • tristanwong