首页 身份证号码归属地查询 身份证号码归属地查询示例代码 身份证查询[Java]

身份证查询示例代码[Java]

作者:xiezhongpian 阅读数:2262 上传时间:2017-05-09

身份证查询

package api.jisuapi.idcard;

import api.util.HttpUtil;
import net.sf.json.JSONObject;

public class Query {

	public static final String APPKEY = "your_appkey_here";// 你的appkey
	public static final String URL = "https://api.jisuapi.com/idcard/query";
	public static final String idcard = "41272519800102067x";

	public static void Get() {
		String result = null;
		String url = URL + "?appkey=" + APPKEY + "&idcard=" + idcard;

		try {
			result = HttpUtil.sendGet(url, "utf-8");
			JSONObject json = JSONObject.fromObject(result);
			if (json.getInt("status") != 0) {
				System.out.println(json.getString("msg"));
			} else {
				JSONObject resultarr = json.optJSONObject("result");
				String province = resultarr.getString("province");
				String city = resultarr.getString("city");
				String town = resultarr.getString("town");
				String lastflag = resultarr.getString("lastflag");
				String sex = resultarr.getString("sex");
				String birth = resultarr.getString("birth");
				System.out.println(province + " " + city + " " + town + " " + lastflag + " " + sex + " " + birth);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}