Archive

Posts Tagged ‘twitter4j’

How to Set Up Twitter4J Quickly in Your Java Project

1. Go to http://twitter4j.org/en/index.html and download the most recently stable version.

2. Add twitter4j-core-2.2.5.jar into project for general use. If you want to use streaming API, add twitter4j-stream-2.2.5.jar into your project.

3. Copy Twitter API property file into your project/bin directory.

4. Test your code example:

public static void main(String[] args) throws Exception {

        Twitter twitter = new TwitterFactory().getInstance();
        int hits = twitter.getRateLimitStatus().getRemainingHits();
        System.out.println(hits);
        Status status = twitter.updateStatus("Really weird!");
        System.out.println("Successfully updated the status to ["
                + status.getText() + "].");

}

Advertisements
Categories: Social Web Tags: