欢迎各位兄弟 发布技术文章
这里的技术是共享的
先到百度API官网查看其有关说明,这是其官网:http://apistore.baidu.com/ 
可在此页面找到相关说明。
打开网址可以看到好几个号码归属地的查询,有些是收费的,有些免费,如果调用不是特别频繁,需要的信息量不是特别多的话,免费的就足够了。我开始看的是第一个接口:http://apistore.baidu.com/apiworks/servicedetail/117.html 
但是百度自己的例子中就可以看出这个接口并不符合我的需求,我要的是可以查询到省市的,显然这个接口只返回给我省。 
再来看这个 http://apistore.baidu.com/apiworks/servicedetail/794.html 
首先看百度所给的例子的结果:  
 
看来这个可以了,百度给了几种不同语言的例子,我只看Java的:
String httpUrl = “http://apis.baidu.com/apistore/mobilenumber/mobilenumber“; 
String httpArg = “phone=15210011578”; 
String jsonResult = request(httpUrl, httpArg); 
System.out.println(jsonResult);
/** 
* @param urlAll 
* :请求接口 
* @param httpArg 
* :参数 
* @return 返回结果 
*/ 
public static String request(String httpUrl, String httpArg) { 
BufferedReader reader = null; 
String result = null; 
StringBuffer sbf = new StringBuffer(); 
httpUrl = httpUrl + “?” + httpArg;
try {
    URL url = new URL(httpUrl);
    HttpURLConnection connection = (HttpURLConnection) url
            .openConnection();
    connection.setRequestMethod("GET");
    // 填入apikey到HTTP header
    connection.setRequestProperty("apikey",  "您自己的apikey");
    connection.connect();
    InputStream is = connection.getInputStream();
    reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
    String strRead = null;
    while ((strRead = reader.readLine()) != null) {
        sbf.append(strRead);
        sbf.append("\r\n");
    }
    reader.close();
    result = sbf.toString();
} catch (Exception e) {
    e.printStackTrace();
}
return result;
}
这里边需要有自己的百度apikey 可参考这个网页http://app.baidu.com/static/cms/getapikey.html
可以把这个方法封装一下作为一个工具类使用了。
来自  http://blog.csdn.net/wbjylk/article/details/50898287
 
接口地址 :http://apis.baidu.com/apistore/mobilenumber/mobilenumber
请求方法 :GET
| 参数名 | 类型 | 必填 | 参数位置 | 描述 | 默认值 | 
|---|---|---|---|---|---|
| string | 是 | header | 
| 参数名 | 类型 | 必填 | 参数位置 | 描述 | 默认值 | 
|---|---|---|---|---|---|
| number | 是 | urlParam | 
{
    "errNum": 0,
    "retMsg": "success",
    "retData": {
        "phone": "15210011578",
        "prefix": "1521001",
        "supplier": "移动 ",
        "province": "北京 ",
        "city": "北京 ",
        "suit": "152卡"
    }
}
"phone": 手机号码,
        "prefix": 手机号码前7位,
        "supplier": "移动 ",
        "province": 省份,
        "city": 城市,
        "suit": "152卡"