当前位置:网站首页>短信平台API接口demo示例-Node/SMS/Send
短信平台API接口demo示例-Node/SMS/Send
2022-04-22 15:54:00 【SUBMAIL赛邮】
DEMO: SMS/Send - 短信发送
var request = require('request');
var crypto = require('crypto');
var appid = "input your appid";
var appkey = "input your appkey";
var api = "https://api-v4.mysubmail.com/sms/send";
//生成加密签名
function BuildSignature(params){
var sorted = [];
for(var key in params) {
sorted[sorted.length] = key;
}
sorted.sort();
var tempDict = {};
for(var i = 0; i < sorted.length; i++) {
tempDict[sorted[i]] = params[sorted[i]];
}
var signStr = "";
for(var key in tempDict) {
signStr += key + '=' + tempDict[key] + '&';
}
signStr = signStr.substring(0, signStr.length-1);
signStr = appid + appkey + signStr + appid + appkey;
var md5sum = crypto.createHash('md5');
md5sum.update(signStr);
return md5sum.digest('hex');
}
//无加密示例
request.post({
url: api,
formData: {
appid:appid,
signature:appkey,
content : "【SUBMAIL】您的验证码是123456,请在6月15日内输入。",
to : "155********"
}
}, function optionalCallback(err, httpResponse, body) {
if (err) {
return console.error(err);
}
console.log(body);
});
//加密示例
request({
uri: "https://api-v4.mysubmail.com/service/timestamp",
method: 'GET'
}, function(error, response, body) {
var result = JSON.parse(body);
var requestParams = {}
requestParams['timestamp'] = result["timestamp"];
requestParams['sign_type'] = "md5";
requestParams['appid'] = appid;
requestParams['sign_version'] = "2";
requestParams['to'] = "155********";
requestParams['signature'] = BuildSignature(requestParams);
requestParams['content'] = "【SUBMAIL】您的验证码是123456,请在6月15日内输入。";
request.post({
url: api,
formData: requestParams
}, function optionalCallback(err, httpResponse, body) {
if (err) {
return console.error(err);
}
console.log(body);
});
});
版权声明
本文为[SUBMAIL赛邮]所创,转载请带上原文链接,感谢
https://blog.csdn.net/SUBMAIL0/article/details/124316629
边栏推荐
- Abbexa丨4E-BP1 细胞 ELISA 试剂盒说明书
- Grafana series (XIII): how to use Loki collection to view kubernetes events
- 短链接生成器,adf.ly、shorte.st、ouo.io、adfoc.us哪个更好,有哪些区别
- Displays whether it is urgent
- ML之RF:kaggle比赛之利用泰坦尼克号数据集建立RF模型对每个人进行获救是否预测
- Small pit on the definition of two-dimensional or multi-dimensional array / slice in go language
- Alibaba P9 handwritten 39 module redis core notes. I had a successful interview and got a salary increase of 7K
- 关键字精确匹配的优缺点
- Zero negative comment on the reputation of Jihu products BAIC Blue Valley has captured the hearts of users with high-end hard core strength
- sql語句———多錶聯查
猜你喜欢
![[model] state space average modeling - step down](/img/f4/c5599e904a891335ab9bd746b74cab.png)
[model] state space average modeling - step down

MySQL operator explanation and regular expression query

Shell脚本中sed使用

年薪37w带12人团队,内推腾讯被拒了。。。
![[deeply understand tcallusdb technology] update data example code - [generic table]](/img/7b/8c4f1549054ee8c0184495d9e8e378.png)
[deeply understand tcallusdb technology] update data example code - [generic table]

【合泰HT32F52352定时器的使用】

Crystal Chem β-乳球蛋白 ELISA 试剂盒 II说明书

SAP UI5 应用开发教程之七十一 - SAP UI5 页面的嵌套路由试读版

太卷了~(2022版)大厂面经 + 详细笔记帮你搞定面试
![[二叉数]相同的树](/img/5d/48bf7a987eeb45d0a1cbf836e3b1e7.png)
[二叉数]相同的树
随机推荐
How can AI intelligent video technology be applied to the scene of daily maintenance and supervision of cultural relics and historic buildings?
Xcode 13 How to use the local swift package
函数指针与回调函数
[writing] thesis writing skills
Ansible practical tips - batch patrol site URL status
关键字精确匹配的优缺点
redis优化系列(一)基于docker搭建Redis主从
OopMap理论篇
4.21总结
Zero negative comment on the reputation of Jihu products BAIC Blue Valley has captured the hearts of users with high-end hard core strength
SAP UI5 应用开发教程之七十一 - SAP UI5 页面的嵌套路由试读版
How to input multi line string in yaml?
服装私域+供应链的管理
E. 2-Letter Strings
Sed in shell script
网站优化后如何降低阿里云国际版服务器成本
Crystal Chem β-乳球蛋白 ELISA 试剂盒 II说明书
Grafana series (IX): introduction to Loki, an open source cloud native logging solution
ML之RF:kaggle比赛之利用泰坦尼克号数据集建立RF模型对每个人进行获救是否预测
【鲲鹏训练营】重庆2022开发者大赛