Java examples for Social Media:Twitter
Make a twitter tweet
import twitter4j.Twitter; import twitter4j.TwitterException; import twitter4j.TwitterFactory; import twitter4j.auth.AccessToken; public final class Tweet { public static void main(String[] args) { if (args.length < 1) { System.exit(-1);/*from www . j a v a 2 s . c o m*/ } Twitter twitter = new TwitterFactory().getInstance(); String consumerKey = ""; String consumerSecret = ""; String accessToken = ""; String accessTokenSecret = ""; twitter.setOAuthConsumer(consumerKey, consumerSecret); twitter.setOAuthAccessToken(new AccessToken(accessToken, accessTokenSecret)); try { twitter.updateStatus(args[0]); System.out.println(args[0]); } catch (TwitterException te) { System.out.println(te.getMessage()); } } }