2012-08-27 40 views
11

微軟有一個非常類似於Google的天氣API(現在看起來已經完全死亡)。我已將其中一個應用程序轉換爲其Feed,但我一直無法找到所有可能的天氣狀況列表。MSN天氣API條件列表?

這對谷歌的天氣API記錄得相當好,但我無法找到MSN天氣API的條件列表。

FWIW,一個範例網址找回數據使用MSN是:

http://weather.service.msn.com/data.aspx?weadegreetype=F&culture=en-US&weasearchstr=Chicago,IL (服務不可用了(2016年1月))

任何人都可以灑在可能的條件下一些輕?我需要它們,以便我可以將條件文本轉換爲圖標。

+0

得到你的天氣位置代碼是谷歌的天氣api死了好還是隻是暫時下降?我有大約15個iphone應用程序使用它,現在我受到用戶挫折感和糟糕評論的轟擊 –

+0

到目前爲止,我所讀到的谷歌天氣api是由igoogle使用的,它不會在2013年11月前用於死亡。 –

+0

@SamBudda不幸的是它看起來好像Google天氣API已經死了。這無疑是從iGoogle(我個人也使用過)轉變的一部分。我有一個Google協作平臺小部件,因爲它依賴Google的天氣API,因此無法使用。 由於API無證,我懷疑我們會聽到谷歌的官方迴應。據我所知,微軟的API也沒有記錄,所以我猜想它也可能會在沒有警告的情況下消失或改變。 –

回答

16

我決定去一個稍微不同的路線,並計算出基於從XML提供的圖標(skycodeskycodeday)的條件。

這是我想出的一個列表。希望這將是對他人幫助的從谷歌的天氣API遷移:

  • 0,1,2,3,4,17,35 - 雷暴
  • 5 - 雨/雪混合
  • 6 - 雨夾雪/雪混合
  • 7 - 雨/雪/冰雹混合
  • 8,9 - 冰
  • 10 - 雨/冰雹混合
  • 11 - 小雨
  • 1 2 - 雨
  • 13 - 小雪
  • 14,16,42,43 - 雪
  • 15 - 暴雪
  • 18,40 - 陣雨
  • 19 - 木屑
  • 20 - 霧
  • 21 - 陰霾
  • 22 - 煙
  • 23,24 - 風
  • 25 - 寒
  • 26 - 清除
  • 27,29,33 - 晴(夜間)
  • 28,30,34 - 晴間多雲
  • 31 - 清除(夜間)
  • 32 - 清除
  • 36 - 熱
  • 37,38 - 散亂雷暴
  • 39 - 零星陣雨
  • 41 - 散亂陣雪
  • 44 - N/A
  • 45 - 散亂陣雨(夜間)
  • 46 - 散亂陣雪(夜間)
  • 47 - 散亂雷暴(夜間)
+0

我也看到這在MSN天氣api「陣雨/清除」 –

+0

@SamBudda爲我的目的,我做了這個分散陣雨。你稱它爲鉛筆,我稱之爲寫作utencil。 ;-) –

4

這是我的功能,能夠容易地您的谷歌API的代碼轉換爲MSN API:

function skycode2image ($skycode) 
{  

$daynight = "na"; 

$skycodes = array ( 
0 => 'thunderstorm', 
1 => 'thunderstorm', 
2 => 'thunderstorm', 
3 => 'thunderstorm', 
4 => 'thunderstorm', 
5 => 'rain_snow', 
6 => 'sleet', 
7 => 'rain_snow', 
8 => 'icy', 
9 => 'icy', 
10 => 'rain_snow', 
11 => 'showers', 
12 => 'rain', 
13 => 'flurries', 
14 => 'snow', 
15 => 'snow', 
16 => 'snow', 
17 => 'thunderstorm', 
18 => 'showers', 
19 => 'dust', 
20 => 'fog', 
21 => 'haze', 
22 => 'haze', 
23 => 'windy', 
24 => 'windy', 
25 => 'icy', 
26 => 'cloudy', 
27 => 'mostly_cloudy', 
28 => 'mostly_cloudy', 
29 => 'partly_cloudy', 
30 => 'partly_cloudy', 
31 => 'sunny', 
32 => 'sunny', 
33 => 'mostly_sunny', 
34 => 'mostly_sunny', 
35 => 'thunderstorm', 
36 => 'hot', 
37 => 'chance_of_tstorm', 
38 => 'chance_of_tstorm', 
39 => 'chance_of_rain', 
40 => 'showers', 
41 - 'chance_of_snow', 
42 => 'snow', 
43 => 'snow', 
44 => 'na', 
45 => 'chance_of_rain', 
46 => 'chance_of_snow', 
47 => 'chance_of_tstorm'); 

$condition = $skycodes[$skycode]; 

if (in_array($skycode,array(27,29,31,33,31,45,46,47))) $daynight = 'night'; 
if (in_array($skycode,array(28,30,32,34,36,37,38,39,41))) $daynight = 'day'; 

return array($condition,$daynight); 

} 
0

我們寫信通知您,微軟的天氣API將不再提供下載,將被停止,因爲2015年4月15日,這意味着它西港島線我不再提供天氣數據。因此,請從當前使用它的任何產品或應用中刪除Microsoft Weather API。

這裏是外部供應商的名單誰可能是能夠支持你的需要,如果你有興趣獲得一個備用的天氣API:

http://api.accuweather.com/ 
http://www.wunderground.com/weather/api/d/pricing.html 
https://developer.forecast.io/ 

免責聲明:微軟和微軟天氣不隸屬於或與任何關聯以任何方式上述公司。

謝謝 微軟天氣團隊

+0

服務是否繼續?我仍然可以調用API – thatsIch

1

似乎有很多誤傳的事情,每當微軟是個問題。 我今天正在測試MSN Weather API;它確實回來了;並每小時返回天氣數據。

我剛纔做了如下[可能非標準]查詢: 「http://weather.service.msn.com/data.aspx?weasearchstr=ny,NY&culture=en-US&weadegreetype=C&src=msn

而且它沒有返回請求正是:

<weatherdata xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><weather weatherlocationcode="wc:USNY0309" weatherlocationname="New York, NY" url="http://a.msn.com/54/en-US/ct40.782,-73.832?ctsrc=msn" imagerelativeurl="http://blob.weather.microsoft.com/static/weather4/en-us/" degreetype="C" provider="Foreca" attribution="http://www.foreca.com/" attribution2="Foreca" lat="40.782" long="-73.832" timezone="-5" alert="" entityid="10109777" encodedlocationname="New+York%2C+NY"><current temperature="4" skycode="29" skytext="Partly Cloudy" date="2016-02-07" observationtime="18:00:00" observationpoint="New York, NY" feelslike="2" humidity="62" winddisplay="9 km/h East" day="Sunday" shortday="Sun" windspeed="9 km/h" /><forecast low="-3" high="5" skycodeday="31" skytextday="Clear" date="2016-02-06" day="Saturday" shortday="Sat" precip="" /><forecast low="1" high="7" skycodeday="28" skytextday="Mostly Cloudy" date="2016-02-07" day="Sunday" shortday="Sun" precip="10" /><forecast low="-3" high="3" skycodeday="16" skytextday="Snow" date="2016-02-08" day="Monday" shortday="Mon" precip="90" /><forecast low="0" high="1" skycodeday="30" skytextday="Partly Sunny" date="2016-02-09" day="Tuesday" shortday="Tue" precip="90" /><forecast low="-2" high="5" skycodeday="28" skytextday="Mostly Cloudy" date="2016-02-10" day="Wednesday" shortday="Wed" precip="50" /><toolbar timewindow="60" minversion="1.0.1965.0" /></weather><weather weatherlocationcode="wc:USNY0996" weatherlocationname="New York, NY" url="http://a.msn.com/54/en-US/ct40.714,-74.006?ctsrc=msn" imagerelativeurl="http://blob.weather.microsoft.com/static/weather4/en-us/" degreetype="C" provider="Foreca" attribution="http://www.foreca.com/" attribution2="Foreca" lat="40.714" long="-74.006" timezone="-5" alert="" entityid="23164" encodedlocationname="New+York%2C+NY"><current temperature="5" skycode="29" skytext="Partly Cloudy" date="2016-02-07" observationtime="18:00:00" observationpoint="New York, NY" feelslike="4" humidity="58" winddisplay="7 km/h East" day="Sunday" shortday="Sun" windspeed="7 km/h" /><forecast low="-7" high="4" skycodeday="31" skytextday="Clear" date="2016-02-06" day="Saturday" shortday="Sat" precip="" /><forecast low="1" high="7" skycodeday="28" skytextday="Mostly Cloudy" date="2016-02-07" day="Sunday" shortday="Sun" precip="10" /><forecast low="-2" high="3" skycodeday="16" skytextday="Snow" date="2016-02-08" day="Monday" shortday="Mon" precip="80" /><forecast low="-1" high="1" skycodeday="30" skytextday="Partly Sunny" date="2016-02-09" day="Tuesday" shortday="Tue" precip="80" /><forecast low="-3" high="5" skycodeday="30" skytextday="Partly Sunny" date="2016-02-10" day="Wednesday" shortday="Wed" precip="50" /><toolbar timewindow="60" minversion="1.0.1965.0" /></weather></weatherdata> 
1

這是四月,2016年,它看起來像微軟天氣數據仍在通過:Washington state weather data(鏈接不同於OP的帖子中顯示的鏈接 - 現在已經停止)。

鏈接中的「wealocations」參數對於每個天氣收集點都是不同的;例如,「USWA0367」用於華盛頓州雷德蒙德。你可以從here.