当前位置:网站首页>Demo example of SMS platform API interface - node / SMS / xsend
Demo example of SMS platform API interface - node / SMS / xsend
2022-04-22 21:59:00 【Submail】
DEMO: SMS/XSend - SMS template sending
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/xsend";
// 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,
project : "9vFM31",
to : "155********",
vars : JSON.stringify({
code : "123456",
time : "6 month 15 Japan "
})
}
}, 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['project'] = "9vFM31";
requestParams['signature'] = BuildSignature(requestParams);
requestParams['vars'] = JSON.stringify({
code : "123456",
time : "6 month 15 Japan "
});
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/202204221554116153.html
边栏推荐
- Leetcode question bank 62 Different paths (recursive C implementation)
- ES6 reflect object
- CSV column extract column extraction
- Mobaxterm cannot drag and upload files after connecting to the virtual machine
- 社会工程学之黑客番外——密码学
- Leaflet modify map center point positioning
- Is EVM compatible important for gamefi development at this stage?
- 从思维走向实践,数字化转型 IT 经营的成功路径
- 使用Pytorch对模型进行训练以及使用保存好的模型进行预测
- PlatoFarm几大创新经济模型,给予当下元宇宙市场的启发
猜你喜欢

超声波模块的使用(STM32/HAL)

EMMC 擦除组的理解

UML diagram related knowledge

【acwing】1135. Happy new year to jtra + * * *

未來源碼 | 吳恩達教授重磅演講:Tips for using a data-centric AI approach

云原生虚拟化:基于 Kubevirt 构建边缘计算实例

MATLAB 基本命令

QQ group chat message statistics for Matplotlib data visualization

How to realize guessing numbers games in C language

在线YAML转XML工具
随机推荐
活动预告 | 4月23日,多场OpenMLDB精彩分享来袭,不负周末好时光!
地球日集合:微软与英特尔邀你Get绿色大使徽章,予能负碳排!
Is EVM compatible important for gamefi development at this stage?
automated testing
企评家为政府打造决策支撑平台
uClibc 和 Glibc 不一样
Interface test mock practice (II) | complete batch manual mock in combination with JQ
Leaflet modify map center point positioning
Use of NPM
MySQL log
BACKBONE,NECK,HEAD
Outside of social engineering -- cryptography
Summary of problems encountered in ffmpeg audio decoding
[operation tutorial] how to turn on the voice intercom function on the national standard gb28181 platform easygbs?
故障分析 | Federated 存储引擎表导致监控线程处于 Opening table 状态
Apache configuration multiport
Understanding of EMMC erasure group
Embedded design and development project - digital tube static display program design
Get rid of the "small workshop" of AI production: how to build a cloud native AI platform based on kubernetes
How to turn off Lenovo antivirus plus