Free ID card api interface code and api interface code

Source: Internet
Author: User

Free ID card api interface code and api interface code

Description: Used to query the region information based on the ID card number.

ID card entity class:

Package org. wx. xhelper. model;/*** ID card entity class * @ author wangxw * @ version 1.0 * @ date Jul 11,201 4 10:46:54 AM */public class IdCard {// ID card number private String idCard; // Date of Birth private String born; // gender private String sex; // region 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 ;}}


Service Interface Class:

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;/*** ID card information service interface class * @ author wangxw * @ version 1.0 * @ date Jul 11,201 4 10:49:57 AM */public class IdCardService {/*** generate ID card information * @ Param cardNo * @ return ID card information * @ throws UnsupportedEncodingException */public static String handle (String cardNo) throws UnsupportedEncodingException {// get ID card IdCard = getIdCardInfo (cardNo ); // store the text information StringBuffer news = new StringBuffer (); if (idcard! = Null) {news. append ("region:" + idcard. getAtt ()). append ("\ n"); news. append ("Date of Birth:" + idcard. getBorn ()). append ("\ n"); news. append ("Gender:" + idcard. getSex ()). append ("\ n");} if (news. length () = 0) {news. append ("ID number "). append (cardNo ). append ("does not exist. Please enter it again! ");} Return news. toString ();}/*** get ID card information * @ param cardNo * @ return returns ID card information */public static IdCard getIdCardInfo (String cardNo) {URL 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 +" & amp; 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 ();}}}


Returned results:

Region: Dongcheng District, Beijing
Date of birth: January 01, 1990
Gender: male


Can Baidu map APIs be called for free? Need a piece of js Code to join the website?

Baidu maps are now available for free.
For details, see pai.baidu.com/map/

Free WEB text message API interface code, free interface, urgent

This still requires a certain amount of cost. If so, it will benefit mankind and continue to focus on it.
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.