获取天气
作者:互联网
1 //根据经纬度获取城市名
public static String getCityNameByLan(String lng,String lat){
try{
String url="http://api.map.baidu.com/geocoder?location="+lat+","+lng+"&output=json";
MyHttpClientResponseResult r= MyHttpClientUtil.requestGet(url);
String s = r.getResponseContent();
JSONObject k = JSONObject.parseObject(s);
String t = k.getJSONObject("result").getJSONObject("addressComponent").getString("city");
return t;
}catch (Exception e){
return "1";
}
}
2 根据城市获取天气数据
MyHttpClientResponseResult r= MyHttpClientUtil.requestGet("http://wthrcdn.etouch.cn/weather_mini?city="+city);
标签:city,return,String,天气,获取,lng,requestGet,MyHttpClientUtil 来源: https://www.cnblogs.com/syscn/p/16173834.html