一 概述
- 界面:输入框,在搜索中框输入查询的城市,下面展示搜索结果
- API:中国天气网实时天气接口,接收参数城市名称,返回结果json字符串
二 天气查询接口
2.1 接口实例
http://wthrcdn.etouch.cn/weather_mini?city=北京
2.2 返回结果
{"data":{"yesterday":{"date":"25日星期六","high":"高温 24℃","fx":"东南风","low":"低温 18℃","fl":"<![CDATA[2级]]>","type":"小雨"},"city":"北京","forecast":[{"date":"26日星期天","high":"高温 19℃","fengli":"<![CDATA[1级]]>","low":"低温 18℃","fengxiang":"东北风","type":"小雨"},{"date":"27日星期一","high":"高温 26℃","fengli":"<![CDATA[1级]]>","low":"低温 17℃","fengxiang":"西南风","type":"多云"},{"date":"28日星期二","high":"高温 24℃","fengli":"<![CDATA[2级]]>","low":"低温 16℃","fengxiang":"南风","type":"多云"},{"date":"29日星期三","high":"高温 25℃","fengli":"<![CDATA[2级]]>","low":"低温 17℃","fengxiang":"东南风","type":"晴"},{"date":"30日星期四","high":"高温 25℃","fengli":"<![CDATA[2级]]>","low":"低温 18℃","fengxiang":"东北风","type":"中雨"}],"ganmao":"感冒低发期,天气舒适,请注意多吃蔬菜水果,多喝水哦。","wendu":"19"},"status":1000,"desc":"OK"}
说明:
字段 | 说明 | 示例 |
---|---|---|
status | 状态码 | 1000 |
desc | 请求结果 | OK |
data | 结果集合 | Object |
data结果展开
字段 | 说明 | 示例 |
---|---|---|
city | 当前城市 | 北京 |
yesterday | 昨天天气情况 | Object |
forecast | 接下来5天的天气(包括今天) | Object |
每天的天气情况
字段 | 说明 | 示例 |
---|---|---|
date | 日期 | 26日星期天 |
high | 高温 | 高温 19℃ |
fengli | 风力 | <![CDATA[1级]]> |
low | 低温 | 低温 18℃ |
fengxiang | 风向 | 东北风 |
type | 天气情况 | 小雨 |