2012-10-10 48 views
0

我正嘗試從我的Android應用發送直接消息。爲此,我使用了Google,並從鏈接中找到以下解決方案。在Twitter4j中,我找到了代碼片段。我在我的Android應用程序嘗試同樣的也有,但是得到了這個問題:Android Twitter sendDirectMessages無法正常工作

http://twitter4j.org/en/code-examples.html

// The factory instance is re-useable and thread safe. 
    Twitter sender = new TwitterFactory().getInstance(); 
    DirectMessage message = sender.sendDirectMessage(recipientId, message); 
    System.out.println("Sent: " message.getText() + " to @" + message.getRecipientScreenName()); 


Issue : 
**10-10 20:04:26.440: E/AndroidRuntime(6935): java.lang.IllegalStateException: Authentication credentials are missing. See http://twitter4j.org/configuration.html for the detail.** 

請幫我走出這個問題。

回答

0

錯誤消息說:

身份驗證憑據丟失。

從Twitter4J Code Examples頁:

要運行示例代碼,您必須twitter4j.properties配置OAuth認證。有關詳細信息,請參見Twitter4J - Configuration

除非您已經登錄,否則不能在Twitter上發送直接消息(不像其他一些功能,例如閱讀隨機用戶的狀態更新)。在代碼示例工作之前,您需要通過Twitter4J Configuration頁面上給出的三種方法之一來配置您的認證憑證。

+0

我在嘗試將直接消息發送給我的追隨者時遇到以下異常。 10-11 11:21:45.930:W/System.err(11946):403:該請求被理解,但它已被拒絕。隨附的錯誤信息將解釋原因。由於更新限制,請求被拒絕時使用此代碼(https://support.twitter.com/articles/15364-about-twitter-limits-update-api-dm-and-following)。 10-11 11:21:45.930:W/System.err(11946):錯誤 - 您不能將郵件發送給沒有關注您的用戶。 – RAJESH