当前位置:网站首页>Demo example of SMS platform API interface - node / SMS / send
Demo example of SMS platform API interface - node / SMS / send
2022-04-22 21:59:00 【Submail】
DEMO: SMS/Send - Text messaging
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";
// Generate encrypted signature
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');
}
// No encryption example
request.post({
url: api,
formData: {
appid:appid,
signature:appkey,
content : "【SUBMAIL】 Your verification code is 123456, Please be there. 6 month 15 Intra day input .",
to : "155********"
}
}, function optionalCallback(err, httpResponse, body) {
if (err) {
return console.error(err);
}
console.log(body);
});
// Encryption example
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】 Your verification code is 123456, Please be there. 6 month 15 Intra day input .";
request.post({
url: api,
formData: requestParams
}, function optionalCallback(err, httpResponse, body) {
if (err) {
return console.error(err);
}
console.log(body);
});
});
版权声明
本文为[Submail]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204221554116194.html
边栏推荐
- 如何在项目中引入SPI
- Old saying: MySQL architecture
- Interview: artificial intelligence job interview - Framework of necessary knowledge for machine learning algorithm engineers in artificial intelligence job hunting
- paho.mqtt.c简单介绍
- ES6 proxy and object defineProperty
- c语言怎么实现猜数字小游戏
- Uclibc is different from glibc
- 华为CDN,哪儿都快
- 超声波模块的使用(STM32/HAL)
- unbelievable! The chief architect of Netease used 500 pages of notes to talk about the network protocol
猜你喜欢
随机推荐
DM8:win7+php7. 3.4(phpstudy)+apache(phpstudy)+dm8. 1-2-84 environment construction
[Luogu] p1157 combined output (DFS)
Common testing techniques
Use of NPM
Packet capture analysis of interface protocol TCP protocol
playwright操作select下的下拉选项
After using easygbs, change to easycvr and change the port to 10000. What is the reason for the Error 404?
MySQL notes (basic)
MySQL configuration parameters and commands
好的测试数据管理,到底要怎么做?
ES6 reflect object
Ten engineering roles of Microsoft
一文学会text-justify,orientation,combine文本属性
ES6 proxy and object defineProperty
Kindeditor displays the source code mode by default on the mobile terminal
paho.mqtt.c简单介绍
Mobaxterm cannot drag and upload files after connecting to the virtual machine
MySQL log
Selenium keyboard operation
Markdown advanced usage









