liujiangyong
1 year ago
9 changed files with 100 additions and 10 deletions
@ -0,0 +1,35 @@ |
|||
'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, |
|||
} |
Loading…
Reference in new issue