7
// Get woeid by lati/long
            HttpGet hg = new HttpGet(
                        "http://where.yahooapis.com/geocode?location=" + latlon + "&flags=J&gflags=R)");
            HttpClient hc = new DefaultHttpClient();
            HttpResponse weatherHR = hc.execute(hg);

            if (weatherHR.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {
                if (DEBUG)
                    Utils.log("", "Location != HttpStatus.SC_OK");
                return null;
            }

我使用了这个 API,之前它工作正常,但是从今天开始它返回一个错误,HttpStatus.SC_OK 不正常。此 API 是否已关闭?谢谢。

4

5 回答 5

10

雅虎已转向名为BOSS的付费服务,但他们确实提供非商业服务:

Yahoo Geo API 的非商业用途

雅虎!继续全面支持在非商业环境中基于 Placefinder 和 PlaceSpotter 构建的开发人员应用程序。您可以通过 YQL 使用这两种服务,并且每个表的查询次数限制为 2000 个。了解有关使用 Placefinder 和 Placespotter YQL 表的更多信息。

使用Placefinder,您可以反向查找纬度和经度:

http://developer.yahoo.com/yql/console/?q=select%20*%20from%20geo.placefinder%20where%20text%3D%2237.416275%2C-122.025092%22%20and%20gflags%3D%22R%22

可以转换成json请求:

http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20geo.placefinder%20where%20text%3D%2237.416275%2C-122.025092%22%20and%20gflags%3D%22R%22&format=json

于 2013-04-18T11:16:24.907 回答
6

是的,它已关闭,请看这里: http ://soup.metwit.com/post/47181933854/an-alternative-to-yahoo-weather-api

于 2013-04-05T09:53:10.397 回答
1

Acity也可以location按如下方式使用:

select * 
from weather.forecast 
where woeid in (
    select woeid 
    from geo.places(1) 
    where text="frankfurt"
) and u="c"

哪里"frankfurt"可以替换为任何选择的位置。

于 2015-01-23T09:23:57.270 回答
1

要通过纬度和经度获取 Yahoo Weather WOEID,您可以使用此

https://query.yahooapis.com/v1/public/yql?q=select%20woeid%20from%20geo.places%20where%20text%3D%22(20,34)%22%20limit%201&diagnostics=false&format=json

您将收到如下回复:

{
  "query":{
    "count":1,
    "created":"2017-03-17T20:34:50Z",
    "lang":"es-AR",
    "results":{
      "place":{
        "woeid":"1435509"
      }
    }
  }
}
于 2017-03-17T20:37:40.167 回答
0

如果还有人需要answear。您有基本网址:

https://query.yahooapis.com/v1/public/yql?q=

现在您必须做出正确的 YQL 语句(将 city 替换为您的城市名称)例如

select * from geo.places where text="city"

现在您必须编码为 URI。您可以使用 javascript 方法:encodeURIComponent()。然后你必须合并 basicURL 和编码的 YQL 语句和

&格式=json

因此,旧金山的整个链接的示例将是:

http://query.yahooapis.com/v1/public/yql?q=select%20 *%20from%20geo.places%20where%20text%3D%22san%20francisco%2C%20ca%22&format=json

现在从响应中你必须得到 WOEID 号码。您可以通过以下方式获取它: 查询>结果>地点>[0]>woeid

所以在Javascript中它会是这样的:

const woeidNumber = responseObject['query']['results']['place'][0]['woeid'];
于 2018-10-10T22:24:14.233 回答