Question

My application uses yahoo's weather feed (XML) to display the weather forecast for the next 5 days. This works nice when the zip code is in the US. For example, the url below gets me the feed for Franklin, MI.

http://xml.weather.yahoo.com/forecastrss/48025_f.xml

I need a similar feed for Canada too, but cant seem to get it working. For example, the postal code of 'Scarborough' is M1M1M1. Tried with

http://xml.weather.yahoo.com/forecastrss/M1M1M1_f.xml

but that does not work.

Thanks in advance

Was it helpful?

Solution

I'm using reliably:

http://weather.yahooapis.com/forecastrss?w=location

where w = WOEID and for Scarborough, Canada w=4369 so:

http://weather.yahooapis.com/forecastrss?w=4369

will return correctly the weather data. More information on the API here.

I'm also using this method for getting the WOEID for a given location name string:

// Create new XML doc
XmlDocument xmldoc = new XmlDocument();
// Get XML doc
xmldoc.Load(string.Format("http://where.yahooapis.com/v1/places.q({0})?appid={1}", place, ApplicationID));
string woeid = xmldoc.GetElementsByTagName("woeid")[0].InnerText;
return woeid;    

But for this to work you will need to obtain an ApplicationID from Yahoo by registering your application.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top