1. 首先,去阿里云市场购买身份证实名认证服务。
因为公司的注册需要实名,所以在阿里云上找了一家实惠。
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…