雅虎天气Web服务
问题描述:
我试图找到一种方法来使用雅虎查询语言与雅虎天气获取一些天气信息。雅虎天气Web服务
由于我住在法国,在一个叫尼斯城市,下面的查询将返回一个错误:
select * from weather.forecast where location='Nice'
我的纬度和经度协调,凭什么我给他们YQL返回天气信息?这项服务是全球性的还是仅仅针对美国?
答
您应该使用另一个YQL数据表。我曾尝试此查询,它工作正常:
SELECT * FROM weather.bylocation WHERE location='Nice' AND unit="c"
我已经加入unit="c"
得到它,它摄氏度,假设你想要的。如果不是,请使用“f”。
在内部,weather.bylocation
表是使用以下两两件事:
- 查找“阿凡上为位置地球标识符(
woeid
), - 然后查找天气此ID的。
请参阅下表的内部:
<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>
关于你提到的关于纬度和经度的用法第二个问题协调: 我不知道是否可以使用他们,但也许你现在甚至不需要这个,对吧?
也很好看:
http://developer.yahoo.com/weather/
http://developer.yahoo.com/geo/geoplanet/guide/concepts.html
,如果你想,当你使用weather.forecast表来改变单位为摄氏度,则需要用AND运算符添加此条件:U =” c“ie:select * from weather.forecast where woeid = 823015 and u =”c“ – golddragon007 2016-02-08 14:36:11