Search in sources :

Example 1 with Place

use of twitter4j.Place in project twitter4j by yusuke.

the class GetGeoDetails method main.

/**
     * Usage: java twitter4j.examples.geo.GetGeoDetails [place id]
     *
     * @param args message
     */
public static void main(String[] args) {
    if (args.length < 1) {
        System.out.println("Usage: java twitter4j.examples.geo.GetGeoDetails [place id]");
        System.exit(-1);
    }
    try {
        Twitter twitter = new TwitterFactory().getInstance();
        Place place = twitter.getGeoDetails(args[0]);
        System.out.println("name: " + place.getName());
        System.out.println("country: " + place.getCountry());
        System.out.println("country code: " + place.getCountryCode());
        System.out.println("full name: " + place.getFullName());
        System.out.println("id: " + place.getId());
        System.out.println("place type: " + place.getPlaceType());
        System.out.println("street address: " + place.getStreetAddress());
        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 retrieve geo details: " + te.getMessage());
        System.exit(-1);
    }
}
Also used : Twitter(twitter4j.Twitter) TwitterFactory(twitter4j.TwitterFactory) TwitterException(twitter4j.TwitterException) Place(twitter4j.Place)

Aggregations

Place (twitter4j.Place)1 Twitter (twitter4j.Twitter)1 TwitterException (twitter4j.TwitterException)1 TwitterFactory (twitter4j.TwitterFactory)1