雅虎天气API检索WOEID [英] Yahoo Weather API WOEID retrieval

查看:398
本文介绍了雅虎天气API检索WOEID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建从自由RSS提要需要雅虎天气数据和基于从RSS馈送检索的数据的彩色六角关联起来的应用程序(PHP)。我遇到的问题是找到一种方法来获取位置code或WOEID没有做手工。

> <一 -

雅虎API,只要你提供一个WOEID发送回一个RSS feed href=\"http://weather.yahooapis.com/forecastrss?w=4097\">http://weather.yahooapis.com/forecastrss?w=4097

是否有这样做的一个道德的方式?我初学的知识告诉我,我必须写一个脚本,将使用术语搜索雅虎和抢了先WOEID,但我会假设雅虎并不希望脚本这样做,它似乎过于复杂...如果没有,有没有替代方案API,这些API将在我使这更容易?

谢谢!


解决方案

为什么不直接使用雅虎GeoPlanet服务,解决一个地方一个WOEID?或使用YQL服务通过它的表访问GeoPlanet?

  http://where.yahooapis.com/v1/places.q('巴里CA')?的appid = [yourappidhere]

<$p$p><$c$c>http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20geo.places%20where%20text%3D%22Barrie%20CA%22&format=xml

无需刮。

干杯

(信息披露,我为雅虎工作,是背后WOEIDs和GeoPlanet组的一部分)

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!

解决方案

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)

这篇关于雅虎天气API检索WOEID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆