Example usage for twitter4j Trend getTweetVolume

List of usage examples for twitter4j Trend getTweetVolume

Introduction

In this page you can find the example usage for twitter4j Trend getTweetVolume.

Prototype

int getTweetVolume();

Source Link

Document

The tweet volume for the last 24 hours if available, -1 otherwise.

Usage

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

/**
 * Usage: java twitter4j.examples.trends.GetPlaceTrends [WOEID=0]
 *
 * @param args message/*  ww  w.  jav a  2 s . c o  m*/
 */
public static void main(String[] args) {
    try {
        int woeid = args.length > 0 ? Integer.parseInt(args[0]) : 1;
        Twitter twitter = new TwitterFactory().getInstance();
        Trends trends = twitter.getPlaceTrends(woeid);

        System.out.println("Showing trends for " + trends.getLocation().getName());

        for (Trend trend : trends.getTrends()) {
            System.out.println(String.format("%s (tweet_volume: %d)", trend.getName(), trend.getTweetVolume()));
        }

        System.out.println("done.");
        System.exit(0);
    } catch (TwitterException te) {
        te.printStackTrace();
        System.out.println("Failed to get trends: " + te.getMessage());
        System.exit(-1);
    } catch (NumberFormatException nfe) {
        nfe.printStackTrace();
        System.out.println("WOEID must be number");
        System.exit(-1);
    }
}