/**
* 测试执行:node ./test.js
*/
var http = require('http')
function post(hostname, path, json_data, callback){
var options = {
hostname: hostname,
port: 80,
path: path,
method: 'POST',
headers: {
'Content-Type':'application/json',
}
}
var req = http.request(options, function(res){
var body ="";
res.setEncoding('utf8');
res.on('data', function(chunk){
//console.log(chunk.toString());
body += chunk;
});
res.on('end', function(){
var json = JSON.parse(body);
callback(json)
});
});
req.on('error', function(e){
console.log('msg:'+e.message);
});
req.write(json_data);
req.end();
}
var hostname = "api.ihuyi.com";
var request_uri = "/mms/v1/batchSend";
//定义请求的数据
var values = {
"api_id":"mms-xxxxxxxx", //APIID(用户中心【富媒体短信】-【5G视频短信】-【产品总览】查看)
"signature":"xxxxxxxxx", //请求验证加密签名(非彩信签名);
签名生成方式:
仅公共参数以ASCII码从小到大排序值,key=value,多值以“&”隔开,拼接之后md5 32位小写; 如:md5(api_id=xxxx&api_key=xxxx&request_id=xxxxxxxx×tamp=xxxxxxx)
APIKEY(用户中心【富媒体短信】-【5G视频短信】-【产品总览】查看)
2、动态密码(生成动态密码方式请看该文档末尾的说明)
"timestamp":1623643787, //东八时区;10位时间戳,时间允许相差±60S
"request_id":"xxxxxxxxxxxx", //请求方请求ID,建议使用唯一ID,比如使用uuid;我方系统会2小时内去重验证处理,防止网络重复攻击;
"product_id":1001, //产品ID
"phone":["18800000000","18800000001"], //手机号数组(最多1万个号码)
"sign_name":"xxxxxxxx", //彩信签名(template_id未填写则必填)
"title":"xxxxxxxxxxxx", //彩信标题(template_id未填写则必填)
"content":[{"con_type":"txt","ext_type":"","data":"将原始内容base64编码"},{"con_type":"img","ext_type":"jpg","data":"将原始内容base64编码"}], //彩信内容和模板ID必须传入1个;当彩信内容和模板ID都传入时,传入内容生效,模板ID属性失效 彩信元素DataItem结构:(具体参照文档9.01)
"template_id":1, //模板ID(内容为空则必填)
"send_time":"2020-08-26 16:08:14", //定时发送时间
}
var json_data = JSON.stringify(values);
//发起请求
post(hostname, request_uri, json_data, function(json){
//打印结果
console.log(json);
})
国内专业互联网团队
21年行业经验
7x24小时售后支持
丰富的行业经验
Copyright © 2004-2025 上海思锐信息技术有限公司 All rights reserved. 沪ICP备07035915号-15 电信增值业务许可证:B2-20160082
服务热线:
4008 808 898
服务热线(工作时间):
4008 808 898
业务咨询(非工作时间):
售后咨询(非工作时间):