注:下面用到的 Yahoo Weather 已经挂了。现在 Yahoo 只提供 Yahoo Weather RSS

官方说明

官方说明文档:Yahoo Weather API for your apps

Yahoo Weather API 的一大特色是 Endpoint 的可读性很强。

select from weather.forecast where woeid in (select woeid from geo.places(1) where text=”nome, ak”)
↓↓
[https://query.yahooapis.com/v1/public/yql?q=select%20
%20from%20weather.forecast%20where%20woeid%20in%20(select%20woeid%20from%20geo.places(1)%20where%20text%3D%22nome%2C%20ak%22)&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys](https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20woeid%20in%20(select%20woeid%20from%20geo.places(1)%20where%20text%3D%22nome%2C%20ak%22)&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys)

PS:ProgrammableWeb API Direcotory 上面收集了很多国内外的 API 信息。

个人使用

下面这个链接就是查询重庆的天气预报:
https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20woeid%20%3D26198378%20and%20u%3D%27c%27&format=json

  • 26198378 是重庆市的 ZIP code

  • c 表示温度单位为 摄氏度 ℃

  • json 返回格式为 JSON

WeatherApi 模型类:
WeatherApiModel.zip