Example usage for twitter4j Twitter getGeoDetails

List of usage examples for twitter4j Twitter getGeoDetails

Introduction

In this page you can find the example usage for twitter4j Twitter getGeoDetails.

Prototype

Place getGeoDetails(String placeId) throws TwitterException;

Source Link

Document

Find out more details of a place that was returned from the PlacesGeoResources#reverseGeoCode(twitter4j.GeoQuery) method.

Usage

From source file:geo.GetGeoDetails.java

License:Apache License

/**
 * Usage: java twitter4j.examples.geo.GetGeoDetails [place id]
 *
 * @param args message//w w w  .ja  v a  2s  . co m
 */
public static void main(String[] args) {
    String s = "939067979a7f3b95";
    try {
        Twitter twitter = new TwitterFactory(Data.getConf().build()).getInstance();
        Place place = twitter.getGeoDetails(s);
        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);
    }
}

From source file:twitter4j.examples.geo.GetGeoDetails.java

License:Apache License

/**
 * Usage: java twitter4j.examples.geo.GetGeoDetails [place id]
 *
 * @param args message//w  w w . j a va2s . c  o  m
 */
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);
    }
}