我正在尝试编写一个简单的应用程序,每次运行该程序时都会发布一条推文。 我一直在试图弄清楚如何获得凭证,但我就是不明白。这是我到目前为止所拥有的:
public void tweet() {
try {
ConfigurationBuilder builder = new ConfigurationBuilder();
builder.setOAuthConsumerKey("consumer key here");
builder.setOAuthConsumerSecret("consumer secret here");
Configuration configuration = builder.build();
TwitterFactory factory = new TwitterFactory(configuration);
twitter = factory.getInstance();
twitter.updateStatus("test");
} catch (TwitterException e) {
e.printStackTrace();
}
}
要明确的是,这不是为了网站或任何东西,只是为了当我在 Eclipse 中运行这个程序时,它应该为我发推文。
如果我不够清楚,请告诉我!
最佳答案
您必须在 Twitter 上注册一个应用程序:https://apps.twitter.com/获取您的代币信息。阅读文档以获取更多信息。
关于java - 尝试使用 Twitter4J 在 java 中发布推文,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35391807/