您是否正受到短信签名报备的困扰?互亿无线解决方案让您最快15分钟内恢复信息传递,马上 注册体验
所有文档
文档中心 > 个人信息核验 > 人像比对(四项)

人像比对(四项)

Node.js对接提交查询接口DEMO示例

本文为您提供了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 = "/idcard/face4compare/Submit.json";

//定义请求的数据
var values = {
    "account":"xxxxxxxx", //APIID(用户中心【认证核验】-【身份信息验证】-【产品总览】查看)
    "password":"xxxxxxxxx", //1、APIKEY(用户中心【认证核验】-【身份信息验证】-【产品总览】查看)
2、动态密码(生成动态密码方式请看该文档末尾的说明) "name":"张三", //身份证姓名 "id_card_no":"40122111******", //身份证号码 "begin_date":"20050712", //有效起始日期,格式:20050712 "end_date":"20050712", //有效截止日期,格式:20050712 (长期有效身份证填 8 个 0) "faceFile":"**.jpg", //使用参数,内容格式需要改为:Content-Type: multipart/form-data 上传人像图片文件,大小为5KB-1MB 格式为jpg、jpeg、png、bmp(faceFile、faceUrl、faceBase64三选一传递) "faceUrl":"http://img.aa.com/demo.jpg", //人像图片网址(faceFile、faceUrl、faceBase64三选一传递) "faceBase64":"******", //图片内容的Base64,如使用Base64,faceFileType为必填(faceFile、faceUrl、faceBase64三选一传递) "faceFileType":"jpg", //faceBase64图片的文件格式:jpg、jpeg、png、bmp "time":"1623643787", //Unix时间戳(10位整型数字,当使用动态密码方式时为必填) } var post_data = querystring.stringify(values); //发起请求 post(hostname, request_uri, post_data, function(json){ //打印结果 console.log(json); })

5分钟快速自助开通免费体验账户

在线咨询
电话咨询

服务热线:

4008 808 898

服务热线(工作时间):

4008 808 898

业务咨询(非工作时间):

售后咨询(非工作时间):