Android Twitter sendDirectMessages不起作用

时间:2012-10-10 15:27:10

标签: android twitter4j

我正在尝试从我的Android应用发送直接消息。为此,我用Google搜索并从链接中找到以下解决方案。在那个Twitter4j中,我找到了代码片段。我也在我的Android应用程序中尝试过相同的操作,但是遇到了问题:

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.**

请帮我解决这个问题。

1 个答案:

答案 0 :(得分:0)

错误消息显示:

  

缺少身份验证凭据。

来自Twitter4J Code Examples页面:

  

要运行示例代码,您需要在twitter4j.properties中配置OAuth凭据。有关详细信息,请参阅Twitter4J - Configuration

除非您已登录,否则您无法在Twitter上发送直接消息(与其他一些功能不同,例如阅读随机用户的状态更新)。您需要在代码示例运行之前,通过Twitter4J配置页面上给出的三种方法之一配置您的身份验证凭据。