2017-02-17 59 views
0

我使用Google Maps Place API限於城市研究,因此我得到的城市,州和國家加上conditionsforecast10day Wunderground APIWunderground API-國家/州/城市組合問題

似乎有時我已經建立了Wunderground API端點問題。

當我在短短一個國家提供一個城市,我有這個端點:

http://api.wunderground.com/api/ {}鍵/conditions/q/IT/Milan.json

和它的工作原理像一個魅力。

當我知道我在尋找的城市可在很多國家,我的「狀態」值添加到終點,就像這樣:

http://api.wunderground.com/api/ {}鍵/環境/ Q/US /PA/Lancaster.json

問題是當我在印度尋找新德里(在這一點上恐怕也爲其他城市):

的http:// API。 wunderground.com/api/{KEY}/條件/ Q/IN/DL/NewDelhi.json

在這種情況下的反應是這樣的:

"error": { 
    "type": "querynotfound", 
    "description": "No cities match your search query" 
} 

但是如果我通過 「ZMW」 調用的參數條件/新德里在印度

http://api.wunderground.com/api/ {}鍵/conditions/q/zmw:00000.1.42182.json

我看到這個 「DISPLAY_LOCATION」 對象:

"city":"New Delhi/Safdarjung", 
"state":"DL", 
"state_name":"India", 
"country":"IN" 

所以,看起來正式的我的端點是正確的。 我在錯什麼?

PS:我使用的是Google Maps Place API,因爲它也是UI準備好的。 :)

回答

0

我已聯繫Wunderground tech support

呃 - 正如他們告訴我的 - 他們的API有點不一致,所以對於美國以外的地方,最好的解決方案是通過lat/lng值進行API調用,以確保始終具有相同的響應結構。

對我而言,通過Google Maps Places可能是因爲我保存了我正在搜索的城市的緯度/經度值。

所以,你可以建立這個端點:

https://api.wunderground.com/api/ {}鍵/環境/ Q/{緯度},{} LNG。json

它的功能就像一個魅力!