本文為您提供了Node.js語言版本的提交查詢接口對接DEMO示例
/**
* 安裝依賴:npm install querystring
* 測試執(zhí)行: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 = "/idcard/id4/Submit.json";
//定義請求的數(shù)據(jù)
var values = {
"account":"xxxxxxxx", //APIID(用戶中心【認證核驗】-【身份信息驗證】-【產(chǎn)品總覽】查看)
"password":"xxxxxxxxx", //1、APIKEY(用戶中心【認證核驗】-【身份信息驗證】-【產(chǎn)品總覽】查看)
2、動態(tài)密碼(生成動態(tài)密碼方式請看該文檔末尾的說明)
"name":"張三", //身份證姓名
"id_card_no":"40122111******", //身份證號碼
"begin_date":"20050712", //有效起始日期,格式:20050712
"end_date":"20050712", //有效截止日期,格式:20050712 (長期有效身份證填 8 個 0)
"time":"1623643787", //Unix時間戳(10位整型數(shù)字,當使用動態(tài)密碼方式時為必填)
}
var post_data = querystring.stringify(values);
//發(fā)起請求
post(hostname, request_uri, post_data, function(json){
//打印結果
console.log(json);
})
國內(nèi)專業(yè)互聯(lián)網(wǎng)團隊
21年行業(yè)經(jīng)驗
7x24小時售后支持
豐富的行業(yè)經(jīng)驗
Copyright ? 2004-2025 上海思銳信息技術有限公司 All rights reserved. 滬ICP備07035915號-15 電信增值業(yè)務許可證:B2-20160082
服務熱線:
4008 808 898
服務熱線(工作時間):
4008 808 898
業(yè)務咨詢(非工作時間):
售后咨詢(非工作時間):
驗證碼已發(fā)送到您的手機,請查收!
輸入驗證碼后,點擊“開通體驗賬戶”按鈕可立即開通體驗賬戶。