android有些应用中需要使用天气预报,来展示今天、未来几天的天气状况,那么具体怎么做呢。
一起来看看
[b]首先需要 国家气象局提供的天气预报接口[/b]
1.风力和湿度: [url]http://www.weather.com.cn/data/sk/101010100.html[/url]
2.气温和天气状况:[url]http://www.weather.com.cn/data/cityinfo/101010100.html[/url]
3.7日气温:[url]http://m.weather.com.cn/data/101010100.html[/url]
后面9位数的是城市编码 101010100 代表北京。
[b]其次 城市代码,访问一个城市地区的天气借口必须要有这个城市地区的代码[/b]
例如:
可通过一下链接获取省级代码:
获取省级代码:[url]http://www.weather.com.cn/data/list3/city.xml?level=1[/url]
[b]最后 有的接口中还会带有一些图片数据,访问地址为[/b]
http://m.weather.com.cn/img/c0.gif http://m.weather.com.cn/img/b0.gif
http://www.weather.com.cn/m/i/weatherpic/29x20/d0.gif
http://www.weather.com.cn/m2/i/icon_weather/29x20/n00.gif
这个图就是天气现象0(晴)的图片,其他天气现象的图片依此类推。
[b]c打头的图片是20*20像素的,
b打头的是50*46像素的,
d打头的是反白的图标,29*20像素,
n打头的是夜间反白图标,29*20像素[/b]
参考文献:[url]http://g.kehou.com/t1029846752.html[/url]
一起来看看
[b]首先需要 国家气象局提供的天气预报接口[/b]
1.风力和湿度: [url]http://www.weather.com.cn/data/sk/101010100.html[/url]
2.气温和天气状况:[url]http://www.weather.com.cn/data/cityinfo/101010100.html[/url]
3.7日气温:[url]http://m.weather.com.cn/data/101010100.html[/url]
后面9位数的是城市编码 101010100 代表北京。
[b]其次 城市代码,访问一个城市地区的天气借口必须要有这个城市地区的代码[/b]
例如:
北京:101010100朝阳:101010300顺义:101010400怀柔:101010500通州:101010600昌平:101010700延庆:101010800丰台:101010900石景山:101011000大兴:101011100房山:101011200密云:101011300门头沟:101011400平谷:101011500八达岭:101011600佛爷顶:101011700汤河口:101011800密云上甸子:101011900斋堂:101012000霞云岭:101012100北京城区:101012200海淀:101010200
可通过一下链接获取省级代码:
获取省级代码:[url]http://www.weather.com.cn/data/list3/city.xml?level=1[/url]
[b]最后 有的接口中还会带有一些图片数据,访问地址为[/b]
http://m.weather.com.cn/img/c0.gif http://m.weather.com.cn/img/b0.gif
http://www.weather.com.cn/m/i/weatherpic/29x20/d0.gif
http://www.weather.com.cn/m2/i/icon_weather/29x20/n00.gif
这个图就是天气现象0(晴)的图片,其他天气现象的图片依此类推。
[b]c打头的图片是20*20像素的,
b打头的是50*46像素的,
d打头的是反白的图标,29*20像素,
n打头的是夜间反白图标,29*20像素[/b]
参考文献:[url]http://g.kehou.com/t1029846752.html[/url]