尝试使用twitter4j lib 将我的webapp与Twitter集成.
我已经注册了我的Twitter网站的应用程序,并获得Consumer key和Consumer secret值.
没什么特别的,标准的OAuth步骤.
码:
public class TwitterService {
private final String CONSUMER_KEY = "xxx";
private final String CONSUMER_SECRET = "yyy";
public String fav() {
Twitter twitter = TwitterFactory.getSingleton();
twitter.setOAuthConsumer(CONSUMER_KEY, CONSUMER_SECRET);
...
Run Code Online (Sandbox Code Playgroud)
例外:
Caused by: java.lang.IllegalStateException: consumer key/secret pair already set.
Run Code Online (Sandbox Code Playgroud)
我没有更多配置key和secret,任何.properties或其他文件.
编辑:
注释行twitter.setOAuthConsumer(CONSUMER_KEY, CONSUMER_SECRET);导致异常:
java.lang.IllegalStateException: OAuth consumer key/secret combination not supplied
Run Code Online (Sandbox Code Playgroud)