Yahoo recently shut their Geo Placefinder API, leaving many who used it for WOEID searching based on latitude & longitude coordinates, scrambling for a solution.
Prerequisites
Download and import JSOUP library (.jar) to your Java project, we’ll using to download JSON from URL. I found that this is the best way to download JSON from any remote url (not just Yahoo API). It’s a one liner and it not only supports variables such as browser User Agents, but also things like timeouts, etc.
Here is my solution in Java
In the following code example. All you need is to insert Latitude & Longitude and the code will print the WOEIDs for any place on earth. It's not the most elegant way of doing this, but it results in a very short code.
String url = "https://query.yahooapis.com/v1/public/yql?q=select%20woeid%20from%20geo.places%20where%20text%3D%22(" + Latitude + "," + Longitude + ")%22%20limit%201&diagnostics=false";
Document yahooApiResponse = Jsoup.connect(url).timeout(10 * 1000).get();
String xmlString = yahooApiResponse.html();
Document doc = Jsoup.parse(xmlString, "", Parser.xmlParser());
System.out.println(doc.select("woeid").first().text().toString());
This is the result WOEID for the following coordinates 43.95 and -79.88:
12697481
Result WOEID was extracted using above code from the following XML:
<query xmlns:yahoo="http://www.yahooapis.com/v1/base.rng" yahoo:count="1" yahoo:created="2016-03-06T05:06:36Z" yahoo:lang="en-US">
<results>
<place xmlns="http://where.yahooapis.com/v1/schema.rng" xmlns:yahoo="http://www.yahooapis.com/v1/base.rng" xml:lang="en-US" yahoo:uri="http://where.yahooapis.com/v1/place/12697481">
<woeid>12697481</woeid>
<placeTypeName code="11">Postal Code</placeTypeName>
<name>L0N</name>
<country code="CA" type="Country" woeid="23424775">Canada</country>
<admin1 code="CA-ON" type="Province" woeid="2344922">Ontario</admin1>
<admin2/>
<admin3/>
<locality1/>
<locality2/>
<postal type="Postal Code" woeid="12697481">L0N</postal>
<centroid>
<latitude>43.984001</latitude>
<longitude>-80.086601</longitude>
</centroid>
<boundingBox>
<southWest>
<latitude>43.76178</latitude>
<longitude>-80.43837</longitude>
</southWest>
<northEast>
<latitude>44.267262</latitude>
<longitude>-79.765717</longitude>
</northEast>
</boundingBox>
<areaRank>1</areaRank>
<popRank>1</popRank>
<timezone type="Time Zone" woeid="56043697">America/Toronto</timezone>
</place>
</results>
</query>
<!-- total: 10 -->
<!-- main-74365d96-e119-11e5-bf99-d89d676f9644 -->
Please ignore naming convention and enjoy!