【发布时间】:2013-10-03 18:56:54
【问题描述】:
我正在使用Open Weather Map API。我还在玩电话。我正在查看 2 个特定调用的结果。一个用于London,另一个用于South Africa 中的Hermanus。我观察到,并非 Hermanus 调用中返回的所有数据都包含在 London 调用中返回的数据中。
这是我的两个电话:
- http://api.openweathermap.org/data/2.5/weather?q=london,uk
- http://api.openweathermap.org/data/2.5/weather?q=hermanus,za
返回伦敦的数据是:
{
"coord": {
"lon":-0.12574,
"lat":51.50853
},
"sys": {
"country":"GB",
"sunrise":1380261352,
"sunset":1380303998
},
"weather": [{
"id":800,
"main":"Clear",
"description":"Sky is Clear",
"icon":"01d"
}],
"base":"gdps stations",
"main": {
"temp":290.22,
"pressure":1016,
"humidity":63,
"temp_min":289.15,
"temp_max":291.48
},
"wind": {
"speed":6.2,
"deg":100
},
"clouds": {
"all":0
},
"dt":1380285272,
"id":2643743,
"name":"London",
"cod":200
}
而为 Hermanus 返回的数据是:
{
"coord": {
"lon":19.234461,
"lat":-34.418701
},
"sys": {
"country":"ZA",
"sunrise":1380255856,
"sunset":1380300203
},
"weather": [{
"id":804,
"main":"Clouds",
"description":"overcast clouds",
"icon":"04d"
}],
"base":"gdps stations",
"main": {
"temp":284.981,
"temp_min":284.981,
"temp_max":284.981,
"pressure":999.07,
"sea_level":1026.12,
"grnd_level":999.07,
"humidity":77
},
"wind": {
"speed":6.71,
"deg":282
},
"rain": {
"3h":0
},
"clouds": {
"all":92
},
"dt":1380285425,
"id":3366880,
"name":"Hermanus",
"cod":200
}
为什么一个包含某些数据而另一个不包含?我怎样才能找出可以从这样的调用中返回的所有内容?以及我如何知道返回的每件商品的含义?
【问题讨论】:
-
返回什么数据完全取决于第三方。他们可能没有针对所有位置的全套数据。您最好向数据提供者自己索取信息。
-
罗里是对的。他们的 api 有时不返回 rain.3h 数据,有时它为 0,我也遇到了同样的问题。也许是时候检查另一个 api,如 forecast.io
标签: javascript jquery jquery-plugins weather weather-api