Update Twitter status - Java Social Media

Java examples for Social Media:Twitter

Description

Update Twitter status

Demo Code



import twitter4j.Twitter;
import twitter4j.TwitterException;
import twitter4j.TwitterFactory;
import twitter4j.auth.AccessToken;


public class PostTweet {
    private static String consumerKey = "key";
    private static String consumerSecret = "key";
    private static String accessToken = "token";
    private static String accessTokenSecret = "token";

    public static void main(String[] args) throws TwitterException {
        Twitter twitter = new TwitterFactory().getInstance();
        twitter.setOAuthConsumer(consumerKey, consumerSecret);
        twitter.setOAuthAccessToken(new AccessToken(accessToken,
                accessTokenSecret));//from  www. j  a v  a2 s  .  co  m

        twitter.updateStatus("Hi!");
    }
}

Related Tutorials