Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
86
rated 0 times [  91] [ 5]  / answers: 1 / hits: 19045  / 12 Years ago, sat, september 15, 2012, 12:00:00

I was using Google Weather API to fetch weather info, but apparently Google had stopped its service. And I am trying to switch to Yahoo Weather API now.



var WOEID = 2502265;  //random WOEID
$.ajax({
url: http://weather.yahooapis.com/forecastjson?w= + WOEID + &u=c,
dataType: 'json',
success: function(data) {
console.log(data);
}
});


However, is there a way that I can get the WOEID by JavaScript only? Because back then I can just do



http://www.google.com/ig/api?hl=en&weather=NYC


and that's it.



It says on the Yahoo weather API page,




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.



Don't care about the Cross-Origin Policy because I am using it in an Chrome extension and it does not apply.


More From » jquery

 Answers
5

Okay I got to know from your comments what exactly you want



You have a place name and you want to get the WOEID of that place name using javascript ajax calls



The url to get that is not defined any where you have to use GeoPlanet service to resolve a place to a WOEID



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


OR you have to use Direct YQL some what like this ( use percent encoding in the url for your city name ) appropriately and try doing an ajax call to this



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

[#83076] Thursday, September 13, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
nia

Total Points: 461
Total Questions: 97
Total Answers: 93

Location: Turks and Caicos Islands
Member since Sun, Mar 7, 2021
3 Years ago
;