今天闲来想做个android的天气预报,百度之,谷歌的天气预报非常的多,下载demo,发现不能访问,至于

原因,你懂得。期间走了很多弯路,为了节省大家时间,就把遇到的坎一一写上。

简单选择后,选用新浪的API

地址:http://php.weather.sina.com.cn/xml.php?password=DJOYnieT8234jlsK&day=0&city=%B8%A3%D6%DD

(红色标记内容为城市名称的转码格式,day=0表示当前天,1表示明天 以此类推,最大为5)

因为期间又看到了http://m.weather.com.cn的API

http://m.weather.com.cn/data/101230101.html

然后悲剧就来了,鬼死神拆的认为city是城市的code。后面也就走了很多弯路,先卖个关子。

新浪天气预报的XML报文

<?xml version="1.0" encoding="UTF-8" ?> 
<!--  published at 2013-05-13 23:37:52 
  --> 
<Profiles>
<Weather>
  <city>福州</city> 
  <status1>多云</status1> 
  <status2>多云</status2> 
  <figure1>duoyun</figure1> 
  <figure2>duoyun</figure2> 
  <direction1>无持续风向</direction1> 
  <direction2>无持续风向</direction2> 
  <power1>≤3</power1> 
  <power2>≤3</power2> 
  <temperature1>28</temperature1> 
  <temperature2>20</temperature2> 
  <ssd>7</ssd> 
  <tgd1>25</tgd1> 
  <tgd2>25</tgd2> 
  <zwx>2</zwx> 
  <ktk>4</ktk> 
  <pollution>3</pollution> 
  <xcz>5</xcz> 
  <zho /> 
  <diy /> 
  <fas /> 
  <chy>1</chy> 
  <zho_shuoming>暂无</zho_shuoming> 
  <diy_shuoming>暂无</diy_shuoming> 
  <fas_shuoming>暂无</fas_shuoming> 
  <chy_shuoming>短袖衫、短裙、短裤、薄型T恤衫、敞领短袖棉衫</chy_shuoming> 
  <pollution_l>一般</pollution_l> 
  <zwx_l></zwx_l> 
  <ssd_l>偏热</ssd_l> 
  <fas_l>暂无</fas_l> 
  <zho_l>暂无</zho_l> 
  <chy_l>薄短袖类</chy_l> 
  <ktk_l>不需要开启</ktk_l> 
  <xcz_l>不适宜</xcz_l> 
  <diy_l>暂无</diy_l> 
  <pollution_s>对空气污染物扩散无明显影响</pollution_s> 
  <zwx_s>紫外线弱</zwx_s> 
  <ssd_s>天气偏热,适当调整穿衣后,仍可达到比较舒适的程度。</ssd_s> 
  <ktk_s>不需要开启空调</ktk_s> 
  <xcz_s>洗车后当日有降水、大风或沙尘天气,不适宜洗车</xcz_s> 
  <gm>1</gm> 
  <gm_l>低发期</gm_l> 
  <gm_s>环境温度较高,要提防长时间在空调环境中引发的空调病;</gm_s> 
  <yd>4</yd> 
  <yd_l>不太适宜</yd_l> 
  <yd_s>天气较热,不太适宜户外运动;</yd_s> 
  <savedate_weather>2013-05-13</savedate_weather> 
  <savedate_life>2013-05-13</savedate_life> 
  <savedate_zhishu>2013-05-13</savedate_zhishu> 
  </Weather>
  </Profiles>
View Code

相关文章:

  • 2021-11-16
  • 2021-11-18
  • 2021-12-15
  • 2021-04-30
  • 2021-07-03
猜你喜欢
  • 2022-12-23
  • 2021-10-25
  • 2021-09-28
  • 2021-05-02
  • 2022-12-23
  • 2021-11-18
  • 2021-09-19
相关资源
相似解决方案