我在发布到 twitter 时遇到问题,它只发布到我的帐户以下是我如何实现它:
在课堂上声明:private ConfigurationBuilder configurationBuilder;
将其放置在表单打开方法时:
configurationBuilder = new ConfigurationBuilder();
configurationBuilder.setDebugEnabled(true)
.setOAuthConsumerKey("*****")
.setOAuthConsumerSecret("*****")
.setOAuthAccessToken("******")
.setOAuthAccessTokenSecret("*****");
放置在按钮的动作侦听器中:
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);
}
根据我的研究,我知道问题出在使用访问令牌密钥上,但是没有它我找不到配置它!