会员通知群发短信以其即时高效、高打开率、个性化定制、成本效益高、跨平台兼容以及法律合规等优势,在现代会员管理和营销策略中占据了重要地位。对于希望提升会员沟通效率、增强用户粘性和促进业务增长的企业而言,合理利用群发短信工具无疑是一个明智的选择。
const http = require('http');
const crypto = require('crypto');
const querystring = require('querystring');
//参数
let url = "http://www.lokapi.cn/smsUTF8.aspx"
let rece = "json"
let username = "17712345678"
let password = "******"
let token = "cae46b2e"
let param = "17712345678|张三|2547|2020-06-22"
let templateid = "951A7DBD"
let passwd = md5(password);
let timestamp = Date.now();
let body = "action=sendtemplate&username=" + username + "&password=" + passwd + "&token=" + token + "×tamp=" + timestamp;
let sign = md5(body);
// 用于请求的选项
let contents = querystring.stringify({
"action": "sendtemplate",
"username": username,
"password": passwd,
"token": token,
"timestamp": timestamp,
"sign": sign,
"rece": rece,
"templateid": templateid,
"param": param
});
let options = {
host: 'www.lokapi.cn',
path: '/smsUTF8.aspx',
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': contents.length
}
}
let req = http.request(options, function (res) {
res.setEncoding('utf8');
res.on('data', function (data) {
console.log("data:", data); //一段html代码
});
});
req.write(contents);
req.end;
function md5(data) {
// 以md5的格式创建一个哈希值
let hash = crypto.createHash('md5');
return hash.update(data).digest('hex').toUpperCase();
}
标签:username,短信,NodeJS,timestamp,发送,token,let,data,md5
From: https://blog.csdn.net/kuaixunhuaruan/article/details/141641850