試圖使用twitter4j lib將我的webapp與Twitter集成。
我已經在twitter上註冊了我的應用程序,並獲得了Consumer key
和Consumer secret
的值。
沒什麼特別,標準OAuth
一步。Twitter集成:已設置消費者密鑰/密鑰對
代碼:
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
不錯,謝謝你Araxia,即工作對我來說 – sergionni 2012-07-25 10:36:53
grt work,thx ..! – 2013-05-15 11:48:17