2012-03-13 118 views
0

我不確定我錯了什麼。我有一個twitter4j.properties文件,我試過一個構造函數,沒有運氣。我不斷收到這個錯誤。Android Twitter4J - 驗證憑證丟失

我使用twitter4j核心功能的Android-2.2.5.jar

java.lang.IllegalStateException:身份驗證憑據丟失。詳細請參閱http://twitter4j.org/configuration.html

 
String twitterpost = "testing"; 

Twitter twitter = new TwitterFactory().getInstance(); 
Status status = twitter.updateStatus(twitterpost); 
System.out.println("Successfully updated the status to [" + status.getText() + "].");

twitter4j.properties位於項目的根目錄中,我也試着移動它,但沒有運氣。

感謝您的任何幫助。

+1

我寫了一篇博客文章Twitter4J http://blog.blundell-apps.com/sending- a-tweet /享受 – Blundell 2012-03-13 23:28:55

回答

0

不知道這樣它會工作,可以考慮使用XAUTH或嘗試OAuth的伎倆波紋管

 //Use xAuth over OAuth , with xAuth you can pass id and pwd to get instance 
    public static Twitter xAuth(String uname, String pwd, Context ctx) 
        throws TwitterException { 
      Twitter twitter = new TwitterFactory().getInstance(uname, pwd); 
      AccessToken accessToken = twitter.getOAuthAccessToken(); 
      save(accessToken, ctx); 
      return getTwitterInstace(accessToken); 
    } 

    // or try this with oAuth 
    System.setProperty("twitter4j.oauth.consumerKey", 
      TWITTER_CONSUMER_KEY); 
      System.setProperty("twitter4j.oauth.consumerSecret", 
      TWITTER_CONSUMER_SECRET); 
+0

感謝您的幫助。 我已經嘗試過oAuth方法,並沒有做到這一點。我會通過oAuth嘗試xAuth並回復你。 – 2012-03-14 16:57:05

0

請添加任何有效的回調URL,然後它會工作,其作品me.and請檢查您的訪問權限也。