我发现大多数类似的解决方案使用XML,但我更愿意使用JSON Objective-C源代码。
有什么建议吗?
我看到了这个:
https://stackoverflow.com/questions/507441/best-weather-apis
我发现大多数类似的解决方案使用XML,但我更愿意使用JSON Objective-C源代码。
有什么建议吗?
我看到了这个:
https://stackoverflow.com/questions/507441/best-weather-apis
注意:此 API 已被 Yahoo 停用,将无法使用!
我在瞎搞一会儿后发现了一个未记录的 Yahoo 天气 API。这是一个示例链接:
http://weather.yahooapis.com/forecastjson?w=12844782&u=c
w
后面的值是 WOEID,而 u
是用来表示单位的。我相信还有更多可用于配置 URL 的选项。
看起来就像这样:
{
"units":{
"temperature":"C",
"speed":"km\/h",
"distance":"km",
"pressure":"mb"
},
"location":{
"location_id":"ITXX0024",
"city":"Como",
"state_abbreviation":"*",
"country_abbreviation":"IT",
"elevation":935,
"latitude":45.81000000000000,
"longitude":9.08000000000000
},
"wind":{
"speed":5.00000000000000,
"direction":"VAR"
},
"atmosphere":{
"humidity":"40",
"visibility":9.99000000000000,
"pressure":982.00000000000000,
"rising":"steady"
},
"url":"http:\/\/weather.yahoo.com\/forecast\/ITXX0024.html",
"logo":"http:\/\/l.yimg.com\/a\/i\/us\/nt\/ma\/ma_nws-we_1.gif",
"astronomy":{
"sunrise":"08:01",
"sunset":"16:42"
},
"condition":{
"text":"Fair",
"code":"34",
"image":"http:\/\/l.yimg.com\/a\/i\/us\/we\/52\/34.gif",
"temperature":9.00000000000000
},
"forecast":[
{
"day":"Today",
"condition":"Mostly Clear",
"high_temperature":7.00000000000000,
"low_temperature":2.00000000000000
},
{
"day":"Tomorrow",
"condition":"Partly Cloudy",
"high_temperature":8.00000000000000,
"low_temperature":2.00000000000000
},
{
"day":"Friday",
"condition":"Sunny",
"high_temperature":8.00000000000000,
"low_temperature":3.00000000000000
},
{
"day":"Saturday",
"condition":"Mostly Sunny",
"high_temperature":7.00000000000000,
"low_temperature":1.00000000000000
},
{
"day":"Sunday",
"condition":"Sunny",
"high_temperature":8.00000000000000,
"low_temperature":1.00000000000000
}
]
}
尝试使用我们最近发布的Aeris Weather API。这个API非常灵活,提供了各种数据选项,并将会有更多的更新。我们还提供免费的开发者账户,可以每天免费获取750次API调用。
http://www.hamweather.com/products/aeris-api/
http://www.hamweather.com/support/documentation/aeris/