使用阿里云实名认证API

706 阅读1分钟

1. 首先,去阿里云市场购买身份证实名认证服务。

链接地址放在这儿 身份实名认证-身份证实名认证-身份证二要素-身份证二要素实名-身份证二要素-身份证二要素校验-身份证二要素核验【北斗数聚】【最新版】_银行卡二元素认证_实名认证接口/API_身份证接口/API-云市场-阿里云 (aliyun.com)

因为公司的注册需要实名,所以在阿里云上找了一家实惠。

image.png

2. 购物之后,我们会得到:AppKey,AppSecret,AppCode

接口的参数很简单,一个身份证号+一个姓名,返回结果就能判断用户是否真实。

public static void main(String[] args) {
    String host = "https://idcardcheck2.hzylgs.com";
    String path = "/api-mall/api/id_card/check";
    String method = "POST";
    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("idcard", "3306811xxxx");
    querys.put("name", "张三");
    Map<String, String> bodys = new HashMap<String, String>();


    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 = HttpUtils2.doPost(host, path, method, headers, querys, bodys);
        System.out.println(response.toString());
        //获取response的body
        System.out.println(EntityUtils.toString(response.getEntity()));
    } catch (Exception e) {
        e.printStackTrace();
    }
}

我这边是用java写的接口,它们文档还提供C#,PHP,Python 反正就是复制黏贴,很方便,非常适合新手。 要是这也不会,那只能上我测试的源码了,源码地址 gitee.com/magicalonio…