尝试使用twitter4j库将我的Web应用与Twitter集成。
我已在Twitter网站上注册了我的应用程序并获得了Consumer key
和Consumer secret
值。
没有什么特别的,标准的OAuth
步骤。
code:
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);
...
异常:
Caused by: java.lang.IllegalStateException: consumer key/secret pair already set.
我没有更多的配置 key
和 secret
的文件,也没有任何 .properties
或其他文件。
编辑:
注释掉twitter.setOAuthConsumer(CONSUMER_KEY, CONSUMER_SECRET);
这一行会导致异常:
java.lang.IllegalStateException: OAuth consumer key/secret combination not supplied