根據手機號 判斷省份和運營商


移動號段:

134 135 136 137 138 139 147 148 150 151 152 157 158 159 165 172 178 182 183 184 187 188 198
聯通號段:

130 131 132 145 146 155 156 166 171 175 176 185 186
電信號段:

133 149 153 173 174 177 180 181 189 191 199

 

判斷省份

public String getAddress(String phone){
String url="http://mobsec-dianhua.baidu.com/dianhua_api/open/location?tel="+phone;
HttpClient httpClient=new DefaultHttpClient();
HttpGet httpGet=new HttpGet(url);
HttpResponse response = null;
String res = null;
try{
response=httpClient.execute(httpGet);
HttpEntity entity = response.getEntity();
res = EntityUtils.toString(entity, "UTF-8");
System.out.println("返回值為:" + res);
JSONObject json= JSONObject.parseObject(res);
System.out.println("1"+json.getString("response"));
String a=json.getString("response");
JSONObject json1= JSONObject.parseObject(a);
System.out.println("2"+json1.getString(phone));
String b=json1.getString(phone);
JSONObject json2= JSONObject.parseObject(b);
System.out.println("3"+json2.getString("detail"));
String c=json2.getString("detail");
JSONObject json3=JSONObject.parseObject(c);
String d=json3.getString("province");

JSONArray array=json3.getJSONArray("area");
String e=array.getJSONObject(0).getString("city");
String f=d+e;
return f;
}catch (Exception e){
e.printStackTrace();
return "系統錯誤";
}
}

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM