本文为您提供了Node.js语言版本的提交查询接口对接DEMO示例
/**
* 安装依赖:npm install querystring
* 测试执行:node ./test.js
*/
var http = require('http')
var querystring = require('querystring');
function post(hostname, path, post_data, callback){
var options = {
hostname: hostname,
port: 80,
path: path,
method: 'POST',
headers: {
'Content-Type':'application/x-www-form-urlencoded',
}
}
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(post_data);
req.end();
}
var hostname = "api.ihuyi.com";
var request_uri = "/veh/translic/Submit.json";
//定义请求的数据
var values = {
"account":"xxxxxxxx", //APIID(用户中心【认证核验】-【车辆与道路运输信息验证】-【产品总览】查看)
"password":"xxxxxxxxx", //1、APIKEY(用户中心【认证核验】-【车辆与道路运输信息验证】-【产品总览】查看)
2、动态密码(生成动态密码方式请看该文档末尾的说明)
"car_no":"沪****", //车牌号码
"plate_color":"4", //车牌颜色代码(1:蓝色;2:黄色;3:黑色;4:白色;5:绿色;9:其他;91:农黄色;92:农绿色;93:黄绿色;94:渐变绿)
"trans_code":"34********40", //道路运输证号
"vin":"****678", //车辆识别代号
"date":"20250101", //证件有效期(YYYYMMDD)
"time":"1623643787", //Unix时间戳(10位整型数字,当使用动态密码方式时为必填)
}
var post_data = querystring.stringify(values);
//发起请求
post(hostname, request_uri, post_data, function(json){
//打印结果
console.log(json);
})
在线咨询
150,000家
企业客户
21年
行业经验
2V1
2对1客户支持