You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
1.2 KiB
35 lines
1.2 KiB
1 year ago
|
'use strict';
|
||
|
|
||
|
const Core = require('@alicloud/pop-core');
|
||
|
|
||
|
const pushBySms = async ({ phone = [], templateCode, accessKey, accessSecret } = {}) => {
|
||
|
try {
|
||
|
if (phone.length) {
|
||
|
const client = new Core({
|
||
|
accessKeyId: accessKey,
|
||
|
accessKeySecret: accessSecret,
|
||
|
endpoint: 'http://dysmsapi.aliyuncs.com', // 固定
|
||
|
apiVersion: '2017-05-25' // 固定
|
||
|
});
|
||
|
const SendSmsRes = await client.request('SendSms', {
|
||
|
"PhoneNumbers": phone.join(','), // 接收短信的手机号码。
|
||
|
"SignName": "隧道智慧运维助手", // 短信签名名称。必须是已添加、并通过审核的短信签名。
|
||
|
"TemplateCode": templateCode, // 短信模板ID。必须是已添加、并通过审核的短信签名;且发送国际/港澳台消息时,请使用国际/港澳台短信模版。
|
||
|
"TemplateParam": JSON.stringify({
|
||
|
struction: 'test',
|
||
|
point: 'test',
|
||
|
number: 1
|
||
|
}) // 短信模板变量对应的实际值,JSON格式。
|
||
|
}, {
|
||
|
method: 'POST'
|
||
|
});
|
||
|
return SendSmsRes
|
||
|
}
|
||
|
} catch (error) {
|
||
|
throw error
|
||
|
}
|
||
|
}
|
||
|
|
||
|
module.exports = {
|
||
|
pushBySms,
|
||
|
}
|