Receive a WOEID by Lat, Long with Yahoos API

后端 未结 11 1900
北荒
北荒 2020-12-07 17:57

i searched a while but found nothing, thats simular to my problem.

i\'m trying to use the YAHOO Weather API, for example: http://weather.yahooapis.com/forecastrss?w=

相关标签:
11条回答
  • 2020-12-07 18:45

    You can use Flickr's reverse geocoding API through YQL.

    Here is a link to the YQL with an example query to find the WOEID for a given lat/lon: http://developer.yahoo.com/yql/console/#h=select%20place.woeid%20from%20flickr.places%20where%20lat%3D43%20and%20lon%3D-94

    The above query can be called directly from your app with this URL (XML/JSON formats available): http://query.yahooapis.com/v1/public/yql?q=select%20place.woeid%20from%20flickr.places%20where%20lat%3D43%20and%20lon%3D-94&format=xml

    0 讨论(0)
  • 2020-12-07 18:47

    Yahoo! PlaceFinder API allows you to find a corresponding WOEID for a latitude/longitude pair. Consider this example web service method call:

    http://where.yahooapis.com/geocode?location=37.42,-122.12&flags=J&gflags=R&appid=zHgnBS4m
    

    You can play with request parameters according to your needs, see Yahoo! PlaceFinder API documentation for more. And you should replace appid with your Yahoo! appid, you can create one here.

    This request returns a response like that, which includes a lot of useful data along with the WOEID:

    {
        "ResultSet": {
            "version": "1.0",
            "Error": 0,
            "ErrorMessage": "No error",
            "Locale": "us_US",
            "Quality": 99,
            "Found": 1,
            "Results": [
                {
                    "quality": 99,
                    "latitude": "37.420000",
                    "longitude": "-122.120000",
                    "offsetlat": "37.420000",
                    "offsetlon": "-122.120000",
                    "radius": 500,
                    "name": "37.42,-122.12",
                    "line1": "3589 Bryant St",
                    "line2": "Palo Alto, CA  94306-4207",
                    "line3": "",
                    "line4": "United States",
                    "house": "3589",
                    "street": "Bryant St",
                    "xstreet": "",
                    "unittype": "",
                    "unit": "",
                    "postal": "94306-4207",
                    "neighborhood": "",
                    "city": "Palo Alto",
                    "county": "Santa Clara County",
                    "state": "California",
                    "country": "United States",
                    "countrycode": "US",
                    "statecode": "CA",
                    "countycode": "",
                    "hash": "",
                    "woeid": 12797284,
                    "woetype": 11,
                    "uzip": "94306"
                }
            ]
        }
    }
    
    0 讨论(0)
  • 2020-12-07 18:48

    This is now available through the recently released PlaceFinder API. Kudos to Yahoo! for providing yet another important piece of the Geo puzzle.

    0 讨论(0)
  • 2020-12-07 18:51

    Seems like you got it the wrong way around. This is the URL on weather.yahoo.com: weather.yahoo.com/united-states/illinois/chicago-2379574/ The last bit is the WOEID for Chicago, i.e. 2379574

    WOEIDs are described in the GeoPlanet docs: http://developer.yahoo.com/geo/geoplanet/guide/concepts.html#woeids

    0 讨论(0)
  • 2020-12-07 18:52

    The former Yahoo Weather API has became deprecated. The new Yahoo Weather API requires a query string to get weather.

    Use the following query string to get weather data by latitude and longitude -
    "https://query.yahooapis.com/v1/public/yql?q=select * from weather.forecast where woeid in (select woeid from geo.places(1) where text=\"(" + latitude + "," + longitude + ")\")&format=json"

    Eg - https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20woeid%20in%20(select%20woeid%20from%20geo.places(1)%20where%20text%3D%22(31.63%2C74.87)%22)&format=json

    0 讨论(0)
提交回复
热议问题