egg-aliyun-sms
v1.5.2
Published
[![NPM version][npm-image]][npm-url] [![build status][travis-image]][travis-url] [![Test coverage][codecov-image]][codecov-url] [![David deps][david-image]][david-url] [![Known Vulnerabilities][snyk-image]][snyk-url] [![npm download][download-image]]
Downloads
21
Readme
egg-aliSMS
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.