下面介绍1下天气接口和其使用方法。天气查询接口为:
http://www.missfeng.com/iserver/services/GetOverallWeatherComponent/restjsr/GetOverallWeather
/"longitude"/"latitude".rjson。这个接口的访问方式为HttpGet,接口中只有两个参数"longitude"和"latitude",替换成你定位取得的经纬度便可。例如: http://www.missfeng.com/iserver/services/GetOverallWeatherComponent/restjsr/GetOverallWeather/116.3/40.rjson获得的是北京海淀区的天气信息。这个接口要求返回的是1个json,json的格式为:{"weatherinfo":{"city":"海淀","cityid":"101010200","temp1":"14℃","temp2":"9℃","weather":"小雨转阴","img1":"d7.gif","img2":"n2.gif","ptime":"08:00","temp":"12","WD":"北风","WS":"0级","SD":"86%","WSE":"0","time":"09:35","isRadar":"1","Radar":"JC_RADAR_AZ9010_JB","njd":"暂无实况","qy":"1018"}}
其中:weatherinfo代表天气信息,city代表所在地,cityid是中国气象局给全国县市的编码,temp1代表当地当日最高气温,temp2代表当日当地最低气温,weather代表当日天气状态,img1代表白每天气状态的图标,img2代表夜晚天气状态的图标,图片资源的访问地址为http://m.weather.com.cn/img/d7.gif,其中d7.gif为获得的img;ptime为天气信息发布的时间,temp为发布时的气温,WD为风向,WS为风级,SD为湿度,WSE为风力,time代表雷达图更新时间,isRadar代表是不是有雷达图,Radar代表雷达图的访问地址,njd为能见度信息,qy为当前气压信息。天气预报接口为:http://www.missfeng.com/iserver/services/GetDetailedWeatherComponent/restjsr
/GetDetailedWeather/"longitude"/"latitude".rjson,其中"longitude"/"latitude"分别为经度、纬度参数例如:
http://www.missfeng.com/iserver/services/GetDetailedWeatherComponent/restjsr/GetDetailedWeather/118.3/37.1.rjson。返回的json为:
({"time":1414719933,"area":[["山东","12"],["滨州","1211"],["博兴","101121102"]],"weather":[{"date":"2014⑴0⑶1","info":{"day":["7","小雨","18","东北风","微风"],"night":["7","小雨","11","东风","微风"]}},{"date":"2014⑴1-01","info":{"dawn":["7","小雨","11","东风","微风"],"day":["7","小雨","16","西北风","微风"],"night":["7","小雨","9","西北风","3⑷ 级"]}},{"date":"2014⑴1-02","info":{"dawn":["7","小雨","9","西北风","3⑷ 级"],"day":["1","多云","14","西北风","3⑷ 级"],"night":["0","晴","5","西北风","微风"]}},{"date":"2014⑴1-03","info":{"dawn":["0","晴","5","西北风","微风"],"day":["0","晴","17","无延续风向","微风"],"night":["0","晴","5","无延续风向","微风"]}},{"date":"2014⑴1-04","info":{"dawn":["0","晴","5","无延续风向","微风"],"day":["0","晴","18","无延续风向","微风"],"night":["1","多云","8","无延续风向","微风"]}}],"pm25":[]});