聚合資料API介面呼叫方法
阿新 • • 發佈:2019-02-14
public String tetapi(String tet) throws Exception{
URLConnection conn = new URL("http://apis.juhe.cn/mobile/get?phone="
+ ""+手機號碼+"&key=你的key").openConnection();
conn.connect(); //連線
InputStream input = conn.getInputStream();
BufferedReader resader = new BufferedReader(new InputStreamReader(input,"UTF-8"));
String jsonString =resader.readLine();
//JSONObject object = jsonObject.getJSONObject("result"); 解析json
// String city1=object.getString("city"); //獲取第二個大括號值 獲取城市
// String province=object.getString("province"); //獲取省份
// System.out.println("省份:"+province+"\t\t城市:"+city1+"\t\t電話:"+tet);
return jsonString;
}
URLConnection conn = new URL("http://apis.juhe.cn/mobile/get?phone="
+ ""+手機號碼+"&key=你的key").openConnection();
conn.connect(); //連線
InputStream input = conn.getInputStream();
BufferedReader resader = new BufferedReader(new InputStreamReader(input,"UTF-8"));
String jsonString =resader.readLine();
//JSONObject object = jsonObject.getJSONObject("result"); 解析json
// String city1=object.getString("city"); //獲取第二個大括號值 獲取城市
// String province=object.getString("province"); //獲取省份
// System.out.println("省份:"+province+"\t\t城市:"+city1+"\t\t電話:"+tet);
return jsonString;
}