Java调用阿里云《身份证实名认证接口》

接口地址:https://market.aliyun.com/products/57000002/cmapi012484.html?spm=5176.2020520132.101.5.muEazf#sku=yuncode648400000代码:public static void main(String[]&nbsp...

接口地址:https://market.aliyun.com/products/57000002/cmapi012484.html?spm=5176.2020520132.101.5.muEazf#sku=yuncode648400000

代码:

public static void main(String[] args) {
	String host = "http://aliyunverifyidcard.haoservice.com";
	String path = "/idcard/VerifyIdcardv2";
	String method = "GET";
	String appcode = "你自己的AppCode";
	Map<String, String> headers = new HashMap<String, String>();
	//最后在header中的格式(中间是英文空格)为Authorization:APPCODE 83359fd73fe94948385f570e3c139105
	headers.put("Authorization", "APPCODE " + appcode);
	Map<String, String> querys = new HashMap<String, String>();
	querys.put("cardNo", "330329199001020022");
	querys.put("realName", "张三");


	try {
		/**
		* 重要提示如下:
		* HttpUtils请从
		* https://github.com/aliyun/api-gateway-demo-sign-java/blob/master/src/main/java/com/aliyun/api/gateway/demo/util/HttpUtils.java
		* 下载
		*
		* 相应的依赖请参照
		* https://github.com/aliyun/api-gateway-demo-sign-java/blob/master/pom.xml
		*/
		HttpResponse response = HttpUtils.doGet(host, path, method, headers, querys);
		System.out.println(response.toString());
		//获取response的body
		//System.out.println(EntityUtils.toString(response.getEntity()));
	} catch (Exception e) {
		e.printStackTrace();
	}
}


返回成功数据:

{
    "error_code": 0,
    "reason": "Success",
    "result": {
        "realname": "张三",
        /*真实姓名*/
        "idcard": "330329199001020022",
        /*身份证号码*/
        "isok": false
        /*true:匹配 false:不匹配*/
        ,
        "IdCardInfor": {
            "area": "山西省太原市清徐县",
            "sex": "男",
            "birthday": "1985-4-10"
        }
    }
}


返回失败数据:

{
    "error_code": 206501,
    "reason": "NoExistERROR",
    "result": {
        "realname": "张三",
        "idcard": "110115198004232418",
        "isok": false
    }
}


条评论

请先 登录 后评论
不写代码的码农
三叔

422 篇文章

作家榜 »

  1. 小编 文章
返回顶部
部分文章转自于网络,若有侵权请联系我们删除