Twitter API on your Java Application


Ever wonder of attaching your tweets to your Java Applications? I searching for the best API out there for this and lucky for me, I found it!

http://twitter4j.org/

A Simple How To:

The first thing we need to do is to create an application within your twitter account, grant it access and generate authentication tokens (although, the consumer tokens will also work and it will be automatically generated upon creating the application).

1) Create an Application in your twitter account: Go To > Settings > Applications > Developers > “here”. You must login with your twitter account (or the account that you will use in your API).

2) Create your application: Enter required fields.

3) A consumer keys will be given to you. if you’re only looking to read status updates, this is sufficient enough for your needs.

The Code:

For this example, I’m using Eclipse IDE.

1) Create a New Java Project and include the Twitter4j Library (download it here).

2) Create a class and check the code below:

Console Output:

And the Actual Twitter Feed:

Download the code :p

Enjoy!

About these ads

One thought on “Twitter API on your Java Application

  1. Pingback: JavaPins

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s