根据手机号 判断省份和运营商

移动号段:

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 "系统错误";
}
}

 

根据手机号 判断省份和运营商

上一篇:AppStore被拒整理


下一篇:go语音基础之append函数的使用