I have problem in posting to twitter, where it only posting with one account which is the first one i tested it with even if it’s logged out or logged in with another account. The following is how i implemented it :
Declare at the class: private ConfigurationBuilder configurationBuilder;
placed it at when the form open method :
configurationBuilder = new ConfigurationBuilder();
configurationBuilder.setDebugEnabled(true)
.setOAuthConsumerKey("*****")
.setOAuthConsumerSecret("*****")
.setOAuthAccessToken("******")
.setOAuthAccessTokenSecret("*****");
Placed at action listener for a Button:
try {
if (jTextPane.getSelectedText().length() <= 127) {
TwitterFactory twitterFactory = new TwitterFactory(configurationBuilder.build());
Twitter twitter = twitterFactory.getInstance();
Status status = twitter.updateStatus("#polytechnic " + jTextPane.getSelectedText());
JOptionPane.showMessageDialog(null, “Tweet Posted Successfully.”);
} else {
JOptionPane.showMessageDialog(null, “You can tweet 127 character only.”);
}
} catch (TwitterException ex) {
Logger.getLogger(PolyNote.class.getName()).log(Level.SEVERE, null, ex);
}