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!
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 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.
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)
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
Find the WOEID of a significant landmark: http://where.yahooapis.com/v1/places.q('sydney%20opera%20house')?appid=[yourappidhere]
Resolve a WOEID to a place: http://where.yahooapis.com/v1/place/2507854?appid=[yourappidhere]
Find the WOEID of a specific place: http://where.yahooapis.com/v1/places.q('northfield%20mn%20usa')?appid=[yourappidhere]
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]
Find the parent of a given WOEID (and return a detailed record): http://where.yahooapis.com/v1/place/638242/parent?select=long&appid=[yourappidhere]
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]
To obtain the representation of a place in JSON format: http://where.yahooapis.com/v1/place/2487956?format=json&appid=[yourappidhere]
To obtain a list of geographies that neighbor a specific WOEID: http://where.yahooapis.com/v1/place/12795711/neighbors?appid=[yourappidhere]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With