List of usage examples for twitter4j Twitter getSimilarPlaces
ResponseList<Place> getSimilarPlaces(GeoLocation location, String name, String containedWithin,
String streetAddress) throws TwitterException;
From source file:geo.GetSimilarPlaces.java
License:Apache License
/** * Usage: java twitter4j.examples.geo.GetSimilarPlaces [latitude] [longitude] [place id] * * @param args message/* ww w.j av a 2 s. c om*/ */ public static void main(String[] args) { if (args.length < 3) { System.out.println( "Usage: java twitter4j.examples.geo.GetSimilarPlaces [latitude] [longitude] [name] [place id]"); System.exit(-1); } try { Twitter twitter = new TwitterFactory().getInstance(); GeoLocation location = new GeoLocation(Double.parseDouble(args[0]), Double.parseDouble(args[1])); String name = args[2]; String containedWithin = null; if (args.length >= 4) { containedWithin = args[3]; } ResponseList<Place> places = twitter.getSimilarPlaces(location, name, containedWithin, null); if (places.size() == 0) { System.out.println("No location associated with the specified condition"); } else { for (Place place : places) { System.out.println("id: " + place.getId() + " name: " + place.getFullName() + " name: " + place.getFullName()); Place[] containedWithinArray = place.getContainedWithIn(); if (containedWithinArray != null && containedWithinArray.length != 0) { System.out.println(" contained within:"); for (Place containedWithinPlace : containedWithinArray) { System.out.println(" id: " + containedWithinPlace.getId() + " name: " + containedWithinPlace.getFullName()); } } } } System.exit(0); } catch (TwitterException te) { te.printStackTrace(); System.out.println("Failed to find similar places: " + te.getMessage()); System.exit(-1); } }