您的位置:首页 > 理论基础 > 计算机网络

针对中国地区的天气预报服务,包括: 查询天气预报的Web站点:http://weather-china.appspot.com/ 基于JSON的REST API接口

2010-07-06 08:09 1151 查看
优点:数据与样式分离

缺点:尚不完善,不支持自动检索城市

Google code: http://code.google.com/p/weather-china/

weather-china封装Yahoo提供的Weather RSS Feed,提供JSON格式的REST API接口,要获取某个城市的天气预报,例如北京,发送如下GET请求:

http://weather-china.appspot.com/api?city=beijing

参数说明:

city:城市名称,可以使用拼音。

返回JSON格式的字符串,使用标准的UTF-8编码,例如:

{
"pub" : "2010-07-05 09:00",
"wind" : {
"chill" : 33,
"direction" : 340,
"speed" : 14.48
},
"astronomy" : {
"sunrise" : "4:49",
"sunset": "19:46"
},
"atmosphere" : {
"humidity" : 26,
"visibility" : 9.99,
"pressure" : 982.05,
"rising": 0
},
"forecasts" : [
{
"date" : "2010-07-05",
"day" : 1,
"code" : 32,
"text" : "晴",
"low" : 23,
"high" : 33,
"image_large" : "http://weather-china.appspot.com/static/w/img/d32.png",
"image_small" : "http://weather-china.appspot.com/static/w/img/s32.png"
},
{
"date" : "2010-07-06",
"day" : 2,
"code" : 32,
"text" : "晴",
"low" : 23,
"high" : 34,
"image_large" : "http://weather-china.appspot.com/static/w/img/d32.png",
"image_small" : "http://weather-china.appspot.com/static/w/img/s32.png"
}
]
}

pub:当前天气信息发布时间;

wind:风力信息;

astronomy:日出和日落时间;

atmosphere:大气信息;

forecasts:包含当天和第二天的天气预报:

date:日期

day:星期

code:天气代码(请在此查询代码含义

text:天气信息

low:最低温度

high:最高温度

image_large:大图片(250x180)地址

image_small:小图片(61x34)地址

天气信息不会频繁更新,可以安全地在客户端缓存1小时。

免费供个人或非营利性组织使用。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐