The free api code of the mobile phone number attribution query, and the mobile phone number attribution api
Query the user's card type, carrier, region, and other information based on the mobile phone number.
Mobile phone home entity
Package org. wx. xhelper. model;/*** mobile phone home * @ author wangxw * @ version 1.0 * @ date Jul 9, 2014 4:03:04 */public class PhoneBelong {// phone number private String phone; // private String area of the region where the mobile phone number is located; // private String ctype of the number card type; // private String operators of the carrier; // The abbreviation is private String simcall; public String getPhone () {return phone;} public void setPhone (String phone) {this. phone = phone;} public String getArea () {return area;} public void setArea (String area) {this. area = area;} public String getCtype () {return ctype;} public void setCtype (String ctype) {this. ctype = ctype;} public String getOperators () {return operators;} public void setOperators (String operators) {this. operators = operators;} public String getSimcall () {return simcall;} public void setSimcall (String simcall) {this. simcall = simcall ;}}
Mobile phone home location service interface
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. phoneBelong;/*** mobile phone attribution Service Interface class * @ author wangxw * @ version 1.0 * @ date Jul 9, 2014 4:07:11 */public class PhoneBelongService {/*** Generate location-specific information * @ param phone * @ return location-specific information * @ throws UnsupportedEncodingException */public static String getPhoneBelongDetail (String phone) throws UnsupportedEncodingException {// get the PhoneBelong phoneBelong = getPhoneBelong (phone); // store the text information StringBuffer news = new StringBuffer (); if (phoneBelong! = Null) {news. append ("number:" + phoneBelong. getPhone ()). append ("\ n"); news. append ("Area Code:" + phoneBelong. getArea ()). append ("\ n"); news. append ("card type:" + phoneBelong. getCtype ()). append ("\ n"); news. append ("carrier:" + phoneBelong. getOperators ()). append ("\ n"); news. append ("region:" + phoneBelong. getSimcall ()). append ("\ n");} if (news. length () = 0) {news. append ("Number "). append (phone ). append ("does not exist. Please enter it again! ");} // Capture the string to avoid exceeding the maximum number of sent characters by 2048if (news. toString (). getBytes ("UTF-8 "). length> 2048) {return news. substring (0, 2000/3 ). concat ("... ");} return news. toString ();}/*** get the home location of the mobile phone * @ param phone * @ return the home location object of the mobile phone */public static PhoneBelong getPhoneBelong (String phone) {URL url = null; phoneBelong phoneBelong = new PhoneBelong (); try {DocumentBuilderFactory factory = DocumentBuilderFactory. newInstance (); DocumentBu Ilder builder = factory. newDocumentBuilder (); url = new URL ("http://api.k780.com: 88 /? App = phone. get & phone = "+ phone +" & amp; appkey = 10003 & sign = b59bc3ef6191eb9f747dd4e83c99f2a4 & format = xml "); Document doc = builder. parse (url. openStream (); NodeList node = doc. getElementsByTagName ("result"); for (int I = 0; I <node. getLength (); I ++) {String area = ""; String ctype = ""; String operators = ""; String simcall = ""; if (doc. getElementsByTagName ("area "). item (I ). getFirstChild ()! = Null) {area = doc. getElementsByTagName ("area "). item (I ). getFirstChild (). getNodeValue ();} if (doc. getElementsByTagName ("ctype "). item (I ). getFirstChild ()! = Null) {ctype = doc. getElementsByTagName ("ctype "). item (I ). getFirstChild (). getNodeValue ();} if (doc. getElementsByTagName ("operators "). item (I ). getFirstChild ()! = Null) {operators = doc. getElementsByTagName ("operators "). item (I ). getFirstChild (). getNodeValue ();} if (doc. getElementsByTagName ("style_simcall "). item (I ). getFirstChild ()! = Null) {simcall = doc. getElementsByTagName ("style_simcall "). item (I ). getFirstChild (). getNodeValue ();} phoneBelong. setPhone (phone); phoneBelong. setArea (area); phoneBelong. setCtype (ctype); phoneBelong. setOperators (operators); phoneBelong. setSimcall (simcall) ;}} catch (Exception e) {e. printStackTrace ();} return phoneBelong ;}}
Query results:
Number: 13800138000
Area No.: 010
Card Type: mobile global card
Operator: Mobile
Region: China, Beijing
! The mobile phone number is used to query the API in the same region. For example, if the Beijing region code is 010 and the return format is json
What do you want to ask? I didn't see the question you want to ask. Do you want a program to query the mobile phone number?
Phone number: Hong Kong
It is a Hong Kong number. But I can't see what the camera is, because the Hong Kong mobile phone and landline are both eight-digit, and there is no mark from the Communications Company.