短信签名快速报备,马上注册寻求客户经理支持!
所有文档
文字识别
文档中心 > 文字识别 > 港澳台通行证OCR识别

港澳台通行证OCR识别

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 = "/ocr/mrtphmt/Submit.json";

//定义请求的数据
var values = {
    "account":"xxxxxxxx", //APIID(用户中心【认证核验】-【OCR识别】-【产品总览】查看)
    "password":"xxxxxxxxx", //1、APIKEY(用户中心【认证核验】-【OCR识别】-【产品总览】查看)
2、动态密码(生成动态密码方式请看该文档末尾的说明) "img_file":"", //图片文件(img_file、img_url二选一传递,小于1MB,支持jpg、png、bmp) "img_url":"", //图片url(img_file、img_url二选一传递,小于1MB,支持jpg、png、bmp) "time":"1623643787", //Unix时间戳(10位整型数字,当使用动态密码方式时为必填) } var post_data = querystring.stringify(values); //发起请求 post(hostname, request_uri, post_data, function(json){ //打印结果 console.log(json); })
在线咨询
服务热线:
4008 808 898

免费体验

提交成功
若短信发送异常,系统将自动给您发送语音验证码,请注意接听电话。

填写验证码后,点击“开通体验账户”自动开通体验账户。

收不到短信验证码?
×