身份证归属地查询免费api接口代码
描写叙述 :依据身份证编号 查询归属地信息。
身份证实体类:
package org.wx.xhelper.model; /**
* 身份证实体类
* @author wangxw
* @version 1.0
* @date Jul 11, 2014 10:46:54 AM
*/
public class IdCard { // 身份证号码
private String idCard; // 出生日期
private String born; // 性别
private String sex; // 所在地区
private String att; public String getIdCard() {
return idCard;
} public void setIdCard(String idCard) {
this.idCard = idCard;
} public String getBorn() {
return born;
} public void setBorn(String born) {
this.born = born;
} public String getSex() {
return sex;
} public void setSex(String sex) {
this.sex = sex;
} public String getAtt() {
return att;
} public void setAtt(String att) {
this.att = att;
} }
服务接口类:
package org.wx.xhelper.service; import java.io.UnsupportedEncodingException;
import java.net.URL;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
import org.wx.xhelper.model.IdCard; /**
* 身份证信息服务接口类
* @author wangxw
* @version 1.0
* @date Jul 11, 2014 10:49:57 AM
*/
public class IdCardService { /**
* 生成身份证信息
* @param cardNo
* @return 返回身份证信息
* @throws UnsupportedEncodingException
*/
public static String getIdCardDetail(String cardNo) throws UnsupportedEncodingException{
// 获取身份证信息
IdCard idcard = getIdCardInfo(cardNo); // 存储文本信息
StringBuffer news = new StringBuffer(); if (idcard != null) {
news.append("所属地区:"+idcard.getAtt()).append("\n");
news.append("出生日期:"+idcard.getBorn()).append("\n");
news.append("性别:"+idcard.getSex()).append("\n");
} if(news.length() == 0){
news.append("身份证号码").append(cardNo).append("不存在,请又一次输入!");
} return news.toString();
} /**
* 获取身份证信息
* @param cardNo
* @return 返回身份证信息
*/
public static IdCard getIdCardInfo(String cardNo){
URL url = null;
IdCard idCard = new IdCard();
try{
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder(); url = new URL("http://api.k780.com:88/? app=idcard.get&idcard="+cardNo+"&appkey=10003&sign=b59bc3ef6191eb9f747dd4e83c99f2a4&format=xml"); System.out.println(url); Document doc = builder.parse(url.openStream());
NodeList node = doc.getElementsByTagName("result"); for(int i=0;i<node.getLength();i++){
String idcard = "";
String born = "";
String sex = "";
String att = "";
if(doc.getElementsByTagName("idcard").item(i).getFirstChild() != null){
idcard = doc.getElementsByTagName("idcard").item(i).getFirstChild().getNodeValue();
}
if(doc.getElementsByTagName("born").item(i).getFirstChild() != null){
born = doc.getElementsByTagName("born").item(i).getFirstChild().getNodeValue();
}
if(doc.getElementsByTagName("sex").item(i).getFirstChild() != null){
sex = doc.getElementsByTagName("sex").item(i).getFirstChild().getNodeValue();
}
if(doc.getElementsByTagName("att").item(i).getFirstChild() != null){
att = doc.getElementsByTagName("att").item(i).getFirstChild().getNodeValue();
}
idCard.setIdCard(idcard);
idCard.setBorn(born);
idCard.setSex(sex);
idCard.setAtt(att);
} }catch(Exception e){
e.printStackTrace();
}
return idCard;
} public static void main(String[] args){
try {
System.out.print(getIdCardDetail("110101199001011118"));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
} }
返回结果:
所属地区:北京市东城区
出生日期:1990年01月01日
性别:男
身份证归属地查询免费api接口代码的更多相关文章
- 手机号码归属地查询免费api接口代码
依据手机号码查询用户的卡类型.运营商.归属地.区域等信息. 手机归属地实体类 package org.wx.xhelper.model; /** * 手机归属地 * @author wangxw * ...
- 身份证归属地查询免费api接口
描写叙述 :依据身份证编号 查询归属地信息. 调用地址: http://api.k780.com:88/? app=idcard.get&idcard=510103195309280011&a ...
- 违章查询免费api接口代码
能够依据城市+车牌号+发动机号查询违章信息列表. 违章实体类 package org.wx.xhelper.model; /** * 违章实体类 * @author wangxw * @version ...
- 快递单号查询免费api接口(PHP示例)
快递单号查询API,可以对接顺丰快递查询,邮政快递查询,中通快递查询等.这些快递物流企业,提供了快递单号自动识别接口,快递单号查询接口等快递物流服务.对于电商企业,ERP服务企业,集成此接口到自己的软 ...
- 公交线路免费api接口代码
描写叙述:本接口主要是依据城市名称 + 线路名称 模糊查找城市公交线路信息. 开源api接口:http://openapi.aibang.com/bus/lines?app_key=keyvalue ...
- 各类无次数限制的免费API接口整理
各类无次数限制的免费API接口整理,主要是聚合数据上和API Store上的一些,还有一些其他的. 聚合数据提供30大类,160种以上基础数据API服务,国内最大的基础数据API服务,下面就罗列一些免 ...
- 网络免费API接口整理
转载自: https://www.cnblogs.com/doit8791/p/9351629.html 从网上看到一些免费API接口,在个人开发小程序等应用练手时可试用. 各类无次数限制的免费API ...
- 各类无次数限制的免费API接口,再也不怕找不到免费API了
各类无次数限制的免费API接口整理,主要是聚合数据上和API Store上的一些,还有一些其他的. 聚合数据提供30大类,160种以上基础数据API服务,国内最大的基础数据API服务,下面就罗列一些免 ...
- 免费API接口记录
用来记录一些无次数限制的免费API接口,主要是聚合数据上和API Store上的一些,还有一些其他的. 手机号码归属地API接口: https://www.juhe.cn/docs/api/id/11 ...
随机推荐
- [LeetCode] Min Stack 栈
Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. pu ...
- Linux和Windows兼容
1. 介绍 我们知道Linux上的应用程序是ELF格式的,而Windows则是PE格式 所以要解决这个问题首先二进制加载问题:其次,就是API问题,两者的API完全不同要实现兼容,就需要构建一个虚拟层 ...
- jmeter登录测试
测试步骤: 1.测试计划--右键添加--Threads--线程组 2. 线程组--右键--http信息头管理器 输入Content-Type=application/json,表示接口请求的默认设置: ...
- 51nod 1050 循环数组最大子段和【环形DP/最大子段和/正难则反】
1050 循环数组最大子段和 基准时间限制:1 秒 空间限制:131072 KB 分值: 10 难度:2级算法题 收藏 关注 N个整数组成的循环序列a[1],a[2],a[3],…,a[n],求该 ...
- Codeforces 791D Bear and Tree Jump(树形DP)
题目链接 Bear and Tree Jumps 考虑树形DP.$c(i, j)$表示$i$最少加上多少后能被$j$整除. 在这里我们要算出所有$c(i, k)$的和. 其中$i$代表每个点对的距离, ...
- 页面css代码
博主原来的页面css代码 (这个是原来的那种效果,差不多弄出来会是这种效果http://www.cnblogs.com/thmyl/) /*simplememory*/ #google_ad_c1, ...
- spring源码学习(一)
Spring作为一个IOC容器,今天我们学习它作为web解析的地方,学习下webmvc包的代码.我们先看下web.xml文件 可以看到通过DispatcherServlet来实现页面的mapper处理 ...
- Delphi Integer 转成单字节
整形不能超过256 b:=Byte(StrToInt(n)); var s: string; b: Byte; begin s := Edit1.Text; b := Byte(Str ...
- 为树莓派(Raspberry pi 2)安装raspbian系统,并用windows自带的远程桌面连接登录
准备工作 树莓派2开发板(保险起见,请装上散热片和风扇): 手机充电器和数据线(输出电压为5V,输出电流为1~2A,电流视开发板上所接附件多少而定): class10 sd小卡,还需要卡架或读卡器: ...
- MyEclipse Html自动提示功能的设置方法
操作方法: windows------preferences----------搜索 html----------找到 html Source这项--------- 右边视图,找到 content a ...