Java身份证实名认证-阿里云API 【姓名、身份证号】
1. 阿里云API市场
https://market.aliyun.com/products/57126001/cmapi00053442.html?spm=5176.2020520132.101.3.a6217218nxxEiy#sku=yuncode47442000022
购买对应套餐

2. 复制AppCode
https://market.console.aliyun.com/imageconsole/index.htm#/?_k=l85e10
云市场-已购买服务

3. AliyunApi
import org.apache.http.HttpResponse;
import org.apache.http.util.EntityUtils;
import java.util.HashMap;
import java.util.Map;public class AliyunApi {public static void main(String[] args) {String host = "https://slysmrzgzl.market.alicloudapi.com";String path = "/get/idcard/checkV2";String method = "GET";String appcode = "你的AppCode";Map<String, String> headers = new HashMap<String, String>();//最后在header中的格式(中间是英文空格)为Authorization:APPCODE 83359fd73fe94948385f570e3c139105headers.put("Authorization", "APPCODE " + appcode);Map<String, String> querys = new HashMap<String, String>();querys.put("name", "姓名");querys.put("idcard", "身份证号码");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的bodySystem.out.println(EntityUtils.toString(response.getEntity()));} catch (Exception e) {e.printStackTrace();}}
}
4. HttpUtils
import org.apache.commons.lang.StringUtils;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.conn.ClientConnectionManager;
import org.apache.http.conn.scheme.Scheme;
import org.apache.http.conn.scheme.SchemeRegistry;
import org.apache.http.conn.ssl.SSLSocketFactory;
import org.apache.http.entity.ByteArrayEntity;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;public class HttpUtils {/*** get** @param host* @param path* @param method* @param headers* @param querys* @return* @throws Exception*/public static HttpResponse doGet(String host, String path, String method,Map<String, String> headers,Map<String, String> querys)throws Exception {HttpClient httpClient = wrapClient(host);HttpGet request = new HttpGet(buildUrl(host, path, querys));for (Map.Entry<String, String> e : headers.entrySet()) {request.addHeader(e.getKey(), e.getValue());}return httpClient.execute(request);}/*** post form** @param host* @param path* @param method* @param headers* @param querys* @param bodys* @return* @throws Exception*/public static HttpResponse doPost(String host, String path, String method,Map<String, String> headers,Map<String, String> querys,Map<String, String> bodys)throws Exception {HttpClient httpClient = wrapClient(host);HttpPost request = new HttpPost(buildUrl(host, path, querys));for (Map.Entry<String, String> e : headers.entrySet()) {request.addHeader(e.getKey(), e.getValue());}if (bodys != null) {List<NameValuePair> nameValuePairList = new ArrayList<NameValuePair>();for (String key : bodys.keySet()) {nameValuePairList.add(new BasicNameValuePair(key, bodys.get(key)));}UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(nameValuePairList, "utf-8");formEntity.setContentType("application/x-www-form-urlencoded; charset=UTF-8");request.setEntity(formEntity);}return httpClient.execute(request);}/*** Post String** @param host* @param path* @param method* @param headers* @param querys* @param body* @return* @throws Exception*/public static HttpResponse doPost(String host, String path, String method,Map<String, String> headers,Map<String, String> querys,String body)throws Exception {HttpClient httpClient = wrapClient(host);HttpPost request = new HttpPost(buildUrl(host, path, querys));for (Map.Entry<String, String> e : headers.entrySet()) {request.addHeader(e.getKey(), e.getValue());}if (StringUtils.isNotBlank(body)) {request.setEntity(new StringEntity(body, "utf-8"));}return httpClient.execute(request);}/*** Post stream** @param host* @param path* @param method* @param headers* @param querys* @param body* @return* @throws Exception*/public static HttpResponse doPost(String host, String path, String method,Map<String, String> headers,Map<String, String> querys,byte[] body)throws Exception {HttpClient httpClient = wrapClient(host);HttpPost request = new HttpPost(buildUrl(host, path, querys));for (Map.Entry<String, String> e : headers.entrySet()) {request.addHeader(e.getKey(), e.getValue());}if (body != null) {request.setEntity(new ByteArrayEntity(body));}return httpClient.execute(request);}/*** Put String* @param host* @param path* @param method* @param headers* @param querys* @param body* @return* @throws Exception*/public static HttpResponse doPut(String host, String path, String method,Map<String, String> headers,Map<String, String> querys,String body)throws Exception {HttpClient httpClient = wrapClient(host);HttpPut request = new HttpPut(buildUrl(host, path, querys));for (Map.Entry<String, String> e : headers.entrySet()) {request.addHeader(e.getKey(), e.getValue());}if (StringUtils.isNotBlank(body)) {request.setEntity(new StringEntity(body, "utf-8"));}return httpClient.execute(request);}/*** Put stream* @param host* @param path* @param method* @param headers* @param querys* @param body* @return* @throws Exception*/public static HttpResponse doPut(String host, String path, String method,Map<String, String> headers,Map<String, String> querys,byte[] body)throws Exception {HttpClient httpClient = wrapClient(host);HttpPut request = new HttpPut(buildUrl(host, path, querys));for (Map.Entry<String, String> e : headers.entrySet()) {request.addHeader(e.getKey(), e.getValue());}if (body != null) {request.setEntity(new ByteArrayEntity(body));}return httpClient.execute(request);}/*** Delete** @param host* @param path* @param method* @param headers* @param querys* @return* @throws Exception*/public static HttpResponse doDelete(String host, String path, String method,Map<String, String> headers,Map<String, String> querys)throws Exception {HttpClient httpClient = wrapClient(host);HttpDelete request = new HttpDelete(buildUrl(host, path, querys));for (Map.Entry<String, String> e : headers.entrySet()) {request.addHeader(e.getKey(), e.getValue());}return httpClient.execute(request);}private static String buildUrl(String host, String path, Map<String, String> querys) throws UnsupportedEncodingException {StringBuilder sbUrl = new StringBuilder();sbUrl.append(host);if (!StringUtils.isBlank(path)) {sbUrl.append(path);}if (null != querys) {StringBuilder sbQuery = new StringBuilder();for (Map.Entry<String, String> query : querys.entrySet()) {if (0 < sbQuery.length()) {sbQuery.append("&");}if (StringUtils.isBlank(query.getKey()) && !StringUtils.isBlank(query.getValue())) {sbQuery.append(query.getValue());}if (!StringUtils.isBlank(query.getKey())) {sbQuery.append(query.getKey());if (!StringUtils.isBlank(query.getValue())) {sbQuery.append("=");sbQuery.append(URLEncoder.encode(query.getValue(), "utf-8"));}}}if (0 < sbQuery.length()) {sbUrl.append("?").append(sbQuery);}}return sbUrl.toString();}private static HttpClient wrapClient(String host) {HttpClient httpClient = new DefaultHttpClient();if (host.startsWith("https://")) {sslClient(httpClient);}return httpClient;}private static void sslClient(HttpClient httpClient) {try {SSLContext ctx = SSLContext.getInstance("TLS");X509TrustManager tm = new X509TrustManager() {public X509Certificate[] getAcceptedIssuers() {return null;}public void checkClientTrusted(X509Certificate[] xcs, String str) {}public void checkServerTrusted(X509Certificate[] xcs, String str) {}};ctx.init(null, new TrustManager[] { tm }, null);SSLSocketFactory ssf = new SSLSocketFactory(ctx);ssf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);ClientConnectionManager ccm = httpClient.getConnectionManager();SchemeRegistry registry = ccm.getSchemeRegistry();registry.register(new Scheme("https", 443, ssf));} catch (KeyManagementException ex) {throw new RuntimeException(ex);} catch (NoSuchAlgorithmException ex) {throw new RuntimeException(ex);}}
}
5. 测试 【信息一致】
姓名和身份证号码正确
{"msg":"成功","success":true,"code":200,"data":{"result":0,"order_no":"876497807026886692","birthday":"20000804","address":"江苏省徐州市泉山区","sex":"女","desc":"一致"}
}
6. 测试 【信息不一致】
姓名不正确, 对应不上身份证号码
{"msg":"成功","success":true,"code":200,"data":{"result":1,"order_no":"205847633280974136","birthday":"20000804","address":"江苏省徐州市泉山区","sex":"女","desc":"不一致"}
}
7. 测试 【身份证号码有误】
{"msg":"请输入有效的身份证号码","success":false,"code":400,"data":null
}
相关文章:
Java身份证实名认证-阿里云API 【姓名、身份证号】
1. 阿里云API市场 https://market.aliyun.com/products/57126001/cmapi00053442.html?spm5176.2020520132.101.3.a6217218nxxEiy#skuyuncode47442000022 购买对应套餐 2. 复制AppCode https://market.console.aliyun.com/imageconsole/index.htm#/?_kl85e10 云市场-已购买服…...
ND协议——无状态地址自动配置 (SLAAC)
参考学习:计算机网络 | 思科网络 | 无状态地址自动配置 (SLAAC) | 什么是SLAAC_瘦弱的皮卡丘的博客-CSDN博客 与 IPv4 类似,可以手动或动态配置 IPv6 全局单播地址。但是,动态分配 IPv6 全局单播地址有两种方法: 如图所示&#…...
iOS开发UITableView的使用,区别Plain模式和Grouped模式
简单赘述一下 的创建步骤 // 创建UITableView self.tableView [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain]; // 设置数据源和代理 self.tableView.dataSource self; self.tableView.delegate self; // 注册自定义UITableViewCe…...
css美化滚动条
/*定义滚动条高宽及背景 高宽分别对应横竖滚动条的尺寸*/ ::-webkit-scrollbar { width: 8px; height: 8px; background-color: rgba(0,0,0,.2); } /*定义滚动条轨道 内阴影圆角*/ ::-webkit-scrollbar-track { -webkit-box…...
【CANoe】XML Test Module使用实例
文章目录 一、实操步骤1、增加XML Test Module节点2、配置XML Test Module节点3、XML Test Module节点增加CAPL脚本(.can文件)4、文件夹结构5、使用仿真节点开始测试6、测试结果与测试报告7、同理,在Test Setup也可如此操作 一、实操步骤 1、增加XML Test Module节…...
oracle的update语句where条件后的索引字段为空时不执行
问题描述: update 表名 set age ‘23’ where id1 and name‘lili’; 当在oracle执行以上sql时执行成功,但是当传入的name为null时,sql不成立。我的表中id和name是联合唯一索引,以为name不会为空,但实际上name可以为空…...
RabbitMQ的特点
RabbitMQ是一个开源的消息中间件,用于在不同的应用程序之间进行异步通信。它支持多种消息传递协议,如AMQP、MQTT、STOMP等。 RabbitMQ具有以下特点: 可扩展性:RabbitMQ可以通过添加更多的节点和队列来实现水平扩展。 可靠性&…...
JS单选框默认选中样式修改,为白色背景中心有黑色小圆点的样式
要修改JavaScript中默认选中的单选框的样式为白色背景并带有黑色小圆点,你可以使用CSS来实现。以下是一个示例,展示如何修改样式: <style>/* 修改默认选中单选框的样式 */input[type"radio"]:checked {appearance: none; /*…...
2023年下半年NPDP考试今天开始报名!
2023年第二次NPDP考试将于2023年12月2日(周六)举行,考试报名相关事项安排如下: 一、考试时间: 12月2日09:00-12:30。 二、报名时间: 10月18日08:00-11月10日23:59。 三、缴费及退考截止时间࿱…...
nfs+rpcbind实现服务器之间的文件共享
NFS简介 NFS服务及Network File System,用于在网络上共享存储,分为2,3,4三个版本,最新为4.1版本。NFS基于RPC协议,RPC为Remote Procedure Call的简写。 应用场景:用于A,B,C三台机器上需要保证被访问到的文件是一样…...
10-k8s-身份认证与鉴权
文章目录 一、ServiceAccount介绍二、ServiceAccount相关的资源对象三、dashboard空间示例 一、ServiceAccount介绍 ServiceAccount(服务账户)概念介绍 1)ServiceAccount是Kubernetes集群中的一种资源对象,用于为Pod或其他资源提供…...
如何分析K8S中的OOMKilled问题(Exit Code 137)
什么是 OOMKilled Kubernetes 错误(Exit Code 137) 当 Kubernetes 集群中的容器超过其内存限制时,Kubernetes 系统可能会终止该容器并显示“OOMKilled”错误,这表明该进程由于内存不足而被终止。此错误的退出代码是 137。 如果遇…...
【0day】泛微e-office OA未授权访问漏洞学习
注:该文章来自作者日常学习笔记,请勿利用文章内的相关技术从事非法测试,如因此产生的一切不良后果与作者无关。 目录 一、漏洞描述 二、影响版本 三、资产测绘 四、漏洞复现...
CSS盒子模型的详细解析
03-盒子模型 作用:布局网页,摆放盒子和内容。 盒子模型-组成 内容区域 – width & height 内边距 – padding(出现在内容与盒子边缘之间) 边框线 – border 外边距 – margin(出现在盒子外面) d…...
【mfc/VS2022】计图实验:绘图工具设计知识笔记2
按钮添加处理程序 1.类视图找到对应类右击,类向导 2. 找到对应的的按钮id 如何将画出的两个相交的圆都显示出来,而不是重叠(如下图)隐藏了一条圆弧 问题如图: 因为矩形和圆心其实是个背景色的封闭图形,所…...
Redis数据结构之quicklist
前言 为了节省内存,Redis 推出了 ziplist 数据类型,采用一种更加紧凑的方式来存储 hash、zset 元素。因为查找的时间复杂度是 O(N),且写入需要重新分配内存,所以它仅适用于小数据量的存储,而且它还存在 连锁更新 的风…...
MMKV(1)
内存准备 通过 mmap 内存映射文件,提供一段可供随时写入的内存块,App 只管往里面写数据,由操作系统负责将内存回写到文件,不必担心 crash 导致数据丢失。 数据组织 数据序列化方面选用 protobuf 协议,pb 在性能和空…...
centos 7.9 源码安装htop
1.下载源码 wget http://sourceforge.net/projects/htop/files/latest/download 2.上传到tmp目录,并解压 tar xvzf htop-1.0.2.tar.gz mv htop-1.0.2 /opt/ 进入到 cd /opt/htop-1.0.2/ 3.编译并安装 ./configure && make && make install 4.…...
Element UI之Button 按钮
Button 按钮 常用的操作按钮。 按需引入方式 如果是完整引入可跳过此步骤 import Vue from vue import { Button } from element-ui import element-ui/lib/theme-chalk/base.css import element-ui/lib/theme-chalk/button.css import element-ui/lib/theme-chalk/icon.cs…...
dig 简明教程
哈喽大家好,我是咸鱼 不知道大家在日常学习或者工作当中用 dig 命令多不多 dig 是 Domain Information Groper 的缩写,对于网络管理员和在域名系统(DNS)领域工作的小伙伴来说,它是一个非常常见且有用的工具。 无论是简单的 DNS 解析查找还…...
dry插件系统解析:如何扩展自定义Docker管理功能
dry插件系统解析:如何扩展自定义Docker管理功能 【免费下载链接】dry moncho/dry: dry(Docker Run Commands)是一款命令行工具,旨在简化对Docker容器的操作管理,提供了一种简洁的方式创建、启动、停止和删除Docker容器…...
RVC与VITS技术对比:检索式vs端到端语音转换的适用场景分析
RVC与VITS技术对比:检索式vs端到端语音转换的适用场景分析 1. 引言 你有没有想过,为什么有些AI翻唱听起来特别像原唱,而有些则感觉“味儿”不太对?或者,为什么有些语音转换工具训练起来飞快,但效果时好时…...
FreeRTOS项目瘦身技巧:如何精简文件并优化工程结构(基于Keil环境)
FreeRTOS项目瘦身实战:Keil环境下的工程精简与结构优化 在嵌入式开发中,FreeRTOS因其轻量级和开源特性成为许多项目的首选RTOS。但随着项目迭代,工程往往会积累大量冗余文件,导致编译速度下降、存储空间浪费。本文将分享一套系统化…...
SmolVLA详细步骤:从start.sh启动到app.py调试的完整开发流程
SmolVLA详细步骤:从start.sh启动到app.py调试的完整开发流程 1. 项目概述与环境准备 SmolVLA是一个专为经济实惠的机器人技术设计的紧凑高效视觉-语言-动作模型。这个模型将视觉感知、语言理解和动作生成融合在一个轻量级架构中,让开发者能够快速构建智…...
计算机毕设 java 基于 Java+Spring 的疫苗接种管理系统的设计与实现 智能疫苗接种预约系统 疫苗接种全流程管理平台
计算机毕设 java 基于 JavaSpring 的疫苗接种管理系统的设计与实现 69geq9(配套有源码 程序 mysql 数据库 论文)本套源码可以先看具体功能演示视频领取,文末有联 xi 可分享在社会对公共卫生安全愈发重视的背景下,疫苗接种作为重要…...
从ResNet到mHC:DeepSeek重构残差连接,额外开销仅6.7%,附复现代码
2015年,由微软亚洲研究院的何恺明团队提出ResNet,ResNet引入残差连接的概念,用以解决深层神经网络训练中的梯度消失/爆炸和网络退化问题,使得训练极深的网络成为可能。 ��1��&#x…...
Python 3.14 JIT vs PyPy 8.3 vs GraalPython:金融风控场景下GC暂停时间对比实测(数据全部脱敏)
第一章:Python 3.14 JIT vs PyPy 8.3 vs GraalPython:金融风控场景下GC暂停时间对比实测(数据全部脱敏)为评估新一代Python运行时在低延迟金融风控场景中的实际表现,我们在统一硬件环境(Intel Xeon Platinu…...
Stable-Diffusion-v1-5-Archive 插件生态入门:十大必备插件安装与使用指南
Stable-Diffusion-v1-5-Archive 插件生态入门:十大必备插件安装与使用指南 刚开始接触 Stable-Diffusion-v1-5-Archive 时,你可能觉得它功能已经很强大了。但用久了就会发现,社区里那些大神们开发的插件,才是真正把创作效率提升到…...
如何在Windows 11中恢复高效工作流:ExplorerPatcher全面配置指南
如何在Windows 11中恢复高效工作流:ExplorerPatcher全面配置指南 【免费下载链接】ExplorerPatcher 提升Windows操作系统下的工作环境 项目地址: https://gitcode.com/GitHub_Trending/ex/ExplorerPatcher Windows 11带来了现代化的界面设计,但许…...
终极指南:5个简单步骤用eqMac提升macOS音频体验 [特殊字符]
终极指南:5个简单步骤用eqMac提升macOS音频体验 🎧 【免费下载链接】eqMac macOS System-wide Audio Equalizer & Volume Mixer 🎧 项目地址: https://gitcode.com/gh_mirrors/eq/eqMac 想为你的Mac打造专业级的音频体验吗&#x…...
