Reputation: 14400
I'm trying to get Yahoo! weather API with temperatures in Celsius.
I've added &u=c
in the request, but it's still returning data in Fahrenheit.
This is the URL I'm using:
And the response:
{"query":{"count":1,"created":"2014-01-13T13:06:43Z","lang":"en-US","results":{"channel":{"item":{"title":"Conditions for Beirut, LE at 1:59 pm EET","lat":"33.82","long":"35.48","link":"http://us.rd.yahoo.com/dailynews/rss/weather/Beirut__LE/*http://weather.yahoo.com/forecast/LEXX0003_f.html","pubDate":"Mon, 13 Jan 2014 1:59 pm EET","condition":{"code":"30","date":"Mon, 13 Jan 2014 1:59 pm EET","temp":"64","text":"Partly Cloudy"},"description":"\n<img src=\"http://l.yimg.com/a/i/us/we/52/30.gif\"/><br />\n<b>Current Conditions:</b><br />\nPartly Cloudy, 64 F<BR />\n<BR /><b>Forecast:</b><BR />\nMon - Partly Cloudy. High: 64 Low: 55<br />\nTue - Cloudy. High: 66 Low: 56<br />\nWed - Mostly Sunny. High: 68 Low: 58<br />\nThu - Sunny. High: 70 Low: 60<br />\nFri - Scattered Showers. High: 65 Low: 57<br />\n<br />\n<a href=\"http://us.rd.yahoo.com/dailynews/rss/weather/Beirut__LE/*http://weather.yahoo.com/forecast/LEXX0003_f.html\">Full Forecast at Yahoo! Weather</a><BR/><BR/>\n(provided by <a href=\"http://www.weather.com\" >The Weather Channel</a>)<br/>\n","forecast":[{"code":"30","date":"13 Jan 2014","day":"Mon","high":"64","low":"55","text":"Partly Cloudy"},{"code":"26","date":"14 Jan 2014","day":"Tue","high":"66","low":"56","text":"Cloudy"},{"code":"34","date":"15 Jan 2014","day":"Wed","high":"68","low":"58","text":"Mostly Sunny"},{"code":"32","date":"16 Jan 2014","day":"Thu","high":"70","low":"60","text":"Sunny"},{"code":"39","date":"17 Jan 2014","day":"Fri","high":"65","low":"57","text":"Scattered Showers"}],"guid":{"isPermaLink":"false","content":"LEXX0003_2014_01_17_7_00_EET"}}}}}}`
Any ideas?
Upvotes: 18
Views: 28207
Reputation: 49
just do this,be sure it will work
add this -->{ and u="c" } at the end of the YQL Query
for example:
YQL Query
select * from weather.forecast where woeid in (select woeid from geo.places(1) where text="greenland") and u="c"
Upvotes: 0
Reputation: 11
You can try this:
YQL Query:
select * from weather.forecast where woeid in (select woeid from geo.places(1) where text="jiangmen,cn") and u="c"
EndPoint:
https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20woeid%20in%20(select%20woeid%20from%20geo.places(1)%20where%20text%3D%22jiangmen%2Ccn%22)%20and%20u%3D%22c%22&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys
This work when I try just now
Upvotes: 1
Reputation: 157
I used the yql
select item from weather.forecast where woeid=22724447 and u='c'
and it worked fine with the results in Celsius. I changed the "LEXX0003" for the real WOEID of that zone and it seems to have worked.
Upvotes: 10
Reputation: 36
Whenever I had to call a temperature that I wanted in Celsius I just used a simple conversion function:
function FtoC(temp) {return Math.round((temp - 32) / (9 / 5));}
Then again, I wanted to toggle between Fahrenheit and Celsius. Just calling the Celsius JSON element from Yahoo is probably better if all you want to use is Celsius.
Upvotes: 1
Reputation: 3250
Better late than never...
var locationQuery = escape("select item from weather.forecast where woeid in (select woeid from geo.places where text='GB-LND') and u='c'"),
locationUrl = "http://query.yahooapis.com/v1/public/yql?q=" + locationQuery + "&format=json&callback=?";
It's easier to read if you break it up. You we're pretty close, just needed the u=c as part of the query, not at the end of the url.
Upvotes: 68