Example usage for twitter4j Location getName

List of usage examples for twitter4j Location getName

Introduction

In this page you can find the example usage for twitter4j Location getName.

Prototype

String getName();

Source Link

Usage

From source file:ontoSentiment.Util.java

public static Integer getTrendLocationId(String locationName, boolean imprimeTrendName)
        throws TwitterException {

    int idTrendLocation = 0;

    ResponseList<Location> locations;
    locations = getTwitter().getAvailableTrends();

    for (Location location : locations) {
        if (imprimeTrendName) {
            System.out.println("Trend name: " + location.getName());
        }/*from  w  w  w  . j  a v a2s  .c  o m*/
        if (location.getName().toLowerCase().equals(locationName.toLowerCase())) {
            idTrendLocation = location.getWoeid();
            break;
        }
    }

    if (idTrendLocation > 0) {
        return idTrendLocation;
    }

    return null;
}

From source file:twitter4j.examples.account.GetAccountSettings.java

License:Apache License

/**
 * Usage: java twitter4j.examples.account.GetAccountSettings
 *
 * @param args arguments doesn't take effect with this example
 *//*from  w  ww  . j a  v a2 s  . com*/
public static void main(String[] args) {
    try {
        Twitter twitter = new TwitterFactory().getInstance();
        AccountSettings settings = twitter.getAccountSettings();
        System.out.println("Sleep time enabled: " + settings.isSleepTimeEnabled());
        System.out.println("Sleep end time: " + settings.getSleepEndTime());
        System.out.println("Sleep start time: " + settings.getSleepStartTime());
        System.out.println("Geo enabled: " + settings.isGeoEnabled());
        System.out.println("Screen name: " + settings.getScreenName());
        System.out.println("Listing trend locations:");
        Location[] locations = settings.getTrendLocations();
        for (Location location : locations) {
            System.out.println(" " + location.getName());
        }
        System.exit(0);
    } catch (TwitterException te) {
        te.printStackTrace();
        System.out.println("Failed to get account settings: " + te.getMessage());
        System.exit(-1);
    }
}

From source file:twitter4j.examples.trends.GetAvailableTrends.java

License:Apache License

/**
 * Usage: java twitter4j.examples.trends.GetAvailableTrends
 *
 * @param args message/*ww  w . j a va 2 s.  c o m*/
 */
public static void main(String[] args) {
    try {
        Twitter twitter = new TwitterFactory().getInstance();
        ResponseList<Location> locations;
        locations = twitter.getAvailableTrends();
        System.out.println("Showing available trends");
        for (Location location : locations) {
            System.out.println(location.getName() + " (woeid:" + location.getWoeid() + ")");
        }
        System.out.println("done.");
        System.exit(0);
    } catch (TwitterException te) {
        te.printStackTrace();
        System.out.println("Failed to get trends: " + te.getMessage());
        System.exit(-1);
    }
}

From source file:wap.twitter.model.TwitterUtility.java

private static Integer getTrendLocationId(String locationName) {

    int idTrendLocation = 0;

    try {//from  www.jav  a 2  s  .  com

        ConfigurationBuilder cb = new ConfigurationBuilder();
        cb.setDebugEnabled(true).setOAuthConsumerKey("yourConsumerKey")
                .setOAuthConsumerSecret("yourConsumerSecret").setOAuthAccessToken("yourOauthToken")
                .setOAuthAccessTokenSecret("yourOauthTokenSecret");

        TwitterFactory tf = new TwitterFactory(cb.build());
        Twitter twitter = tf.getInstance();

        ResponseList<Location> locations;
        locations = twitter.getAvailableTrends();

        for (Location location : locations) {
            if (location.getName().toLowerCase().equals(locationName.toLowerCase())) {
                idTrendLocation = location.getWoeid();
                break;
            }
        }

        if (idTrendLocation > 0) {
            return idTrendLocation;
        }

        return null;

    } catch (TwitterException te) {
        te.printStackTrace();
        System.out.println("Failed to get trends: " + te.getMessage());
        return null;
    }

}