Trying to solve compilation problems in jzd's answer, here is what I came up with:
public static void sendToTwitter(String tweet) {
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setDebugEnabled(true)
.setOAuthConsumerKey("---")
.setOAuthConsumerSecret("---")
.setOAuthAccessToken("---")
.setOAuthAccessTokenSecret("---");
TwitterFactory tf = new TwitterFactory(cb.build());
Twitter t = tf.getInstance();
try {
t.updateStatus(tweet);
} catch (TwitterException te) {
te.printStackTrace();
}
}
And it works the way I wanted it. Thank you very much.
source
share