开发者

Yahoo Weather WebService

I'm trying to find a way to get some weather information with Yahoo Weather using Yahoo Query Language.

As I'm living in France, in a city called Nice, the following query return开发者_Go百科s an error:

select * from weather.forecast where location='Nice'

I have the latitude and longitude coordinated, so how can I give them to YQL to return the weather info? Is this service worldwide or just for the US?


You should use another YQL datatable instead. I have tried this query and it works fine:

SELECT * FROM weather.bylocation WHERE location='Nice' AND unit="c"

This is the YQL console

I have added unit="c" to get it it Celsius, assuming that you want that. If not, use "f".

Internally the weather.bylocation table is using the following two things:

  1. Lookup of the 'where on earth identifier (woeid) for the location,
  2. and then lookup of the weather for this id.

See the internals of that table below:

    <execute><![CDATA[
      default xml namespace ='http://where.yahooapis.com/v1/schema.rng'; 
      var x = y.query('select woeid from geo.places(1) where text="'+location+'"');
      var s = x.results;
      var woeid = s..woeid;
      var weather = y.rest('http://weather.yahooapis.com/forecastrss?w='+woeid+'&u='+unit).get().response;
      response.object = <weather>{weather}</weather>;
    ]]></execute>

Regarding your 2nd question about usage of latitude and longitude coordinated: I don't know if you can use them but maybe you don't even need this anymore now, right?

Also good read:

http://developer.yahoo.com/weather/

http://developer.yahoo.com/geo/geoplanet/guide/concepts.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜