Integrating Twitter via Java

This you want to integrate to Twitter from Java you can use the following library JTwitter.

Try out the twitter integration with the following coding:


package de.vogella.twitter.test;

import java.util.List;

import winterwell.jtwitter.Twitter;
import winterwell.jtwitter.Twitter.User;

public class TwitterTest {
	private static final String user ="your-user";
	private static final String pw ="your-password";

	public static void main(String[] args) {
		// Make a Twitter object
               Twitter twitter = new TwitterFactory().getInstance(user,pw);
		// Print Lars Vogel status
		System.out.println(twitter.getStatus("vogella"));
		// Set my status
		twitter.setStatus("@vogella messing with Twitter in Java");
		List<User> followers = twitter.getFollowers();
		for (User user : followers) {
			System.out.println(user.getName());
		}
	}
}

Another Java Twitter Library is Twitter4J.

Tags:
Filed under: Java, Web

Comments

  1. Meera Says:

    Hi Lars,
    Have you written any Java application using Facebook? What libraries do you need and do you have any sample code?
    Thanks,
    Meera

  2. Lars Vogel Says:

    @Meera: No, so far I have not develop for Facebook

  3. Fazal Says:

    @Meera: You can develop Java application which connects to Facebook using the facebook-java-api project hosted on Google Code [http://code.google.com/p/facebook-java-api/]. Te only thing is Facebook does not support this project officially because of which the APIs are updated once in a while only.

  4. Fazal Says:

    @Meera: You can check this tutorial for details: http://blog.theunical.com/facebook-integration/facebook-java-api-example-to-publish-on-wall/

  5. orang_letrik Says:

    wow..superb.
    just sent my first tweet using these library

    =)


Switch to our mobile site