Twitter XAuth Tweet - Java Social Media

Java examples for Social Media:Twitter

Description

Twitter XAuth Tweet

Demo Code

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

public final class XAuthTweet {
    public static void main(String[] args) {
        if (args.length < 3) {
            System.exit(-1);//w  ww . ja  va 2s . c o m
        }
        Twitter twitter = new TwitterFactory().getInstance();
        String consumerKey = "";
        String consumerSecret = "";

        twitter.setOAuthConsumer(consumerKey, consumerSecret);
        try {
            AccessToken accessToken = twitter.getOAuthAccessToken(args[0],
                    args[1]);
            System.out.println(+ accessToken.getToken());
            System.out.println(+ accessToken.getTokenSecret());
            twitter.updateStatus(args[2]);
            System.out.println("" + args[2]);
        } catch (TwitterException te) {
            System.out.println(te.getMessage());
        }
    }
}

Related Tutorials