Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Yahoo Weather API WOEID retrieval

I'm creating an app (PHP) that takes yahoo weather data from the free RSS feed and correlates it with a colour hex based on data retrieved from the RSS feed. The issue I'm having is finding a way to grab the location code or WOEID without doing it manually.

Yahoos API sends back an RSS feed as long as you provide a WOEID -> http://weather.yahooapis.com/forecastrss?w=4097

Is there an ethical way of doing this? My beginner knowledge tells me I have to write a script that would search yahoo using the term and grab the first WOEID, but I would assume yahoo doesn't want scripts doing this and it seems overcomplicated... If not, are there any alternative APIs that would make this easier on me?

Thanks!

like image 688
askon Avatar asked Nov 30 '09 21:11

askon


People also ask

How do you get Woeid?

To find your WOEID, browse or search for your city from the Weather home page. The WOEID is in the URL for the forecast page for that city. You can also get the WOEID by entering your zip code on the home page. But I want to get it by JavaScript, not manually go to weather.yahoo.com and find out the WOEID.

What is Yahoo Weather API?

What is a Yahoo weather API? A Yahoo weather application programming interface (API) is a service that allows the Yahoo Weather RSS feed to be added to a website or client application.


2 Answers

Why not just use the Yahoo! GeoPlanet service to resolve a place to a WOEID? Or use the YQL service to access GeoPlanet via it's table?

http://where.yahooapis.com/v1/places.q('Barrie CA')?appid=[yourappidhere] 

or

http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20geo.places%20where%20text%3D%22Barrie%20CA%22&format=xml 

No need for scraping.

Cheers

G

(Disclosure; I work for Yahoo! and am part of the group behind WOEIDs and GeoPlanet)

like image 142
Gary Gale Avatar answered Oct 15 '22 01:10

Gary Gale


I got some useful information from: http://developer.yahoo.com/geo/geoplanet/

And

http://developer.yahoo.com/geo/geoplanet/guide/api-reference.html#api-countries

  1. Find the WOEID of a significant landmark: http://where.yahooapis.com/v1/places.q('sydney%20opera%20house')?appid=[yourappidhere]

  2. Resolve a WOEID to a place: http://where.yahooapis.com/v1/place/2507854?appid=[yourappidhere]

  3. Find the WOEID of a specific place: http://where.yahooapis.com/v1/places.q('northfield%20mn%20usa')?appid=[yourappidhere]

  4. Obtain a range of WOEIDs that match a given place, ordered by the most likely: http://where.yahooapis.com/v1/places.q('springfield');start=0;count=5?appid=[yourappidhere]

  5. Find the parent of a given WOEID (and return a detailed record): http://where.yahooapis.com/v1/place/638242/parent?select=long&appid=[yourappidhere]

  6. Return the Placename for a given WOEID in a specific language (where it exists): http://where.yahooapis.com/v1/places.q('usa')?lang=fr&appid=[yourappidhere]

  7. To obtain the representation of a place in JSON format: http://where.yahooapis.com/v1/place/2487956?format=json&appid=[yourappidhere]

  8. To obtain a list of geographies that neighbor a specific WOEID: http://where.yahooapis.com/v1/place/12795711/neighbors?appid=[yourappidhere]

like image 33
NguyenDat Avatar answered Oct 15 '22 01:10

NguyenDat