php Yahoo Weather API WOEID 检索
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1822650/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Yahoo Weather API WOEID retrieval
提问by askon
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.
我正在创建一个应用程序 (PHP),它从免费的 RSS 提要中获取雅虎天气数据,并将其与基于从 RSS 提要中检索到的数据的颜色十六进制相关联。我遇到的问题是找到一种无需手动操作即可获取位置代码或 WOEID 的方法。
Yahoos API sends back an RSS feed as long as you provide a WOEID -> http://weather.yahooapis.com/forecastrss?w=4097
只要您提供 WOEID,Yahoos API 就会发回 RSS 提要 -> 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?
有没有道德的方式来做到这一点?我的初学者知识告诉我我必须编写一个脚本来使用该术语搜索雅虎并获取第一个 WOEID,但我认为雅虎不希望脚本这样做并且看起来过于复杂......如果没有,还有其他选择吗可以让我更轻松的 API?
Thanks!
谢谢!
回答by Gary Gale
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?
为什么不直接使用 Yahoo! GeoPlanet 服务将一个地方解析为 WOEID?或者使用 YQL 服务通过它的表访问 GeoPlanet?
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
G
(Disclosure; I work for Yahoo! and am part of the group behind WOEIDs and GeoPlanet)
(披露;我为雅虎工作!并且是 WOEID 和 GeoPlanet 背后的小组的一员)
回答by NguyenDat
I got some useful information from: http://developer.yahoo.com/geo/geoplanet/
我从以下位置获得了一些有用的信息:http: //developer.yahoo.com/geo/geoplanet/
And
和
http://developer.yahoo.com/geo/geoplanet/guide/api-reference.html#api-countries
http://developer.yahoo.com/geo/geoplanet/guide/api-reference.html#api-countries
Find the WOEID of a significant landmark: http://where.yahooapis.com/v1/places.q('sydney%20opera%20house')?appid=[yourappidhere]
Resolve a WOEID to a place: http://where.yahooapis.com/v1/place/2507854?appid=[yourappidhere]
Find the WOEID of a specific place: http://where.yahooapis.com/v1/places.q('northfield%20mn%20usa')?appid=[yourappidhere]
Obtain a range of WOEIDs that match a given place, ordered by the most likely: http://where.yahooapis.com/v1/places.q('springfield');start=0;count=5?appid=[yourappidhere]
Find the parent of a given WOEID (and return a detailed record): http://where.yahooapis.com/v1/place/638242/parent?select=long&appid=[yourappidhere]
Return the Placename for a given WOEID in a specific language (where it exists): http://where.yahooapis.com/v1/places.q('usa')?lang=fr&appid=[yourappidhere]
To obtain the representation of a place in JSON format: http://where.yahooapis.com/v1/place/2487956?format=json&appid=[yourappidhere]
To obtain a list of geographies that neighbor a specific WOEID: http://where.yahooapis.com/v1/place/12795711/neighbors?appid=[yourappidhere]
查找重要地标的 WOEID:http: //where.yahooapis.com/v1/places.q ('sydney%20opera%20house')?appid=[yourappidhere]
将 WOEID 解析到某个地方:http://where.yahooapis.com/v1/place/2507854?appid=[yourappidhere]
查找特定地点的WOEID: http://where.yahooapis.com/v1/places.q ('northfield%20mn%20usa')?appid=[yourappidhere]
获取与给定地点匹配的一系列 WOEID,按最可能的顺序排序:http://where.yahooapis.com/v1/places.q ('springfield');start=0;count=5?appid=[yourappidhere ]
找到给定WOEID的父级(并返回详细记录):http://where.yahooapis.com/v1/place/638242/parent?select=long&appid=[yourappidhere]
以特定语言(它存在的地方)返回给定 WOEID 的地名:http: //where.yahooapis.com/v1/places.q ('usa')?lang=fr&appid=[yourappidhere]
以 JSON 格式获取地点的表示:http://where.yahooapis.com/v1/place/2487956?format=json&appid=[yourappidhere]
要获取与特定 WOEID 相邻的地理位置列表:http://where.yahooapis.com/v1/place/12795711/neighbors?appid=[yourappidhere]
回答by OnlyMAJ
Yahoo! Geo Technologies is pleased to announce the availability of PlaceFinder support in YQL. The geo.placefinder table allows users to make requests to PlaceFinder via YQL queries. The new table provides several different ways to access PlaceFinder. A description of the supported requests and parameters can be retrieved using http://query.yahooapis.com/v1/public/yql?q...&appid=test. Here are a few examples:
雅虎!Geo Technologies 很高兴地宣布在 YQL 中提供 PlaceFinder 支持。geo.placefinder 表允许用户通过 YQL 查询向 PlaceFinder 发出请求。新表提供了几种不同的访问 PlaceFinder 的方法。可以使用http://query.yahooapis.com/v1/public/yql?q...&appid=test检索支持的请求和参数的描述。这里有一些例子:
Geocoding a street address (1600 Pennsylvania Ave, Washington, DC) using free-form input format:
使用自由格式输入格式对街道地址 (1600 Pennsylvania Ave, Washington, DC) 进行地理编码:
http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20geo.placefinder%20where%20text%3D%221600%20Pennsylvania%20Ave%2C%20Washington%2C%20DC%22&appid=test
Geocoding a street address (701 First Ave, Sunnyvale, CA 94089) using multi-line input format:
使用多行输入格式对街道地址 (701 First Ave, Sunnyvale, CA 94089) 进行地理编码:
http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20geo.placefinder%20where%20line1%3D%22701%20First%20Ave%22%20and%20line2%3D%22Sunnyvale%2C%20CA%2094089%22&appid=test
Geocoding an airport code (SFO):
对机场代码 (SFO) 进行地理编码:
http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20geo.placefinder%20where%20text%3D%22sfo%22&appid=test
Geocoding a point of interest (POI) in French:
用法语对兴趣点 (POI) 进行地理编码:
http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20geo.placefinder%20where%20text%3D%22Eiffel%20Tower%22%20and%20lang%3D%22fr%22&appid=test
Reverse geocoding using geographic coordinates:
使用地理坐标进行反向地理编码:
http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20geo.placefinder%20where%20text%3D%2237.416275%2C%20-122.025092%22%20and%20gflags%3D%22R%22&appid=test
Geocoding a street address (701 First Ave, Sunnyvale, CA 94089) using parsed input format:
使用解析的输入格式对街道地址 (701 First Ave, Sunnyvale, CA 94089) 进行地理编码:
http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20geo.placefinder%20where%20house%3D%22701%22%20and%20street%3D%22First%20Ave%22%20and%20city%3D%22Sunnyvale%22%20and%20state%3D%22CA%22%20and%20postal%3D%2294089%22&appid=test
Determining the nearest cross streets and timezone for an address:
确定地址最近的十字路口和时区:
http://query.yahooapis.com/v1/public/yql?q=select%20line1%2C%20line2%2C%20line3%2C%20line4%2C%20cross%2C%20timezone%20from%20geo.placefinder%20where%20text%3D%22701%20First%20Ave%2C%20Sunnyvale%2C%20CA%22%20and%20flags%3D%22T%22%20and%20gflags%3D%22C%22&appid=test
This example illustrates the YQL ability to select only specified fields from the response
此示例说明了 YQL 仅从响应中选择指定字段的能力

