【问题标题】:Android twitter send direct messageAndroid twitter 发送直接消息
【发布时间】:2013-08-03 08:48:48
【问题描述】:

我已将 twitter 与我的应用程序集成。 Twitter 发布工作正常。现在我正在尝试向其中一位追随者发送直接消息,但它显示 IlligalStateException:Authentication credentials are missing ensureAuthenticationEnabled.

这是我发送直接消息的代码:

//SEND DIRECT MESSAGE TO TWITTER FRIENDS WALL
public static void sendDirectMessageToFriend(String friendId,String messsage){
    Twitter sender =new TwitterFactory().getInstance();
    try {
        DirectMessage message = sender.sendDirectMessage(friendId, messsage);
    } catch (TwitterException e) {
        e.printStackTrace();
    }
    //System.out.println("Sent: " message.getText() + " to @" + message.getRecipientScreenName());
}

【问题讨论】:

  • 我也面临同样的问题任何分享的想法.......

标签: android twitter


【解决方案1】:

看看报错信息:

缺少身份验证凭据。

根据twitter4j的代码示例页面:

要运行示例代码,您需要在 twitter4j.properties 中配置 OAuth 凭据。有关如何执行此操作的说明,请参阅http://twitter4j.org/en/configuration.html

您必须登录才能在 Twitter 上发送直接消息。您需要通过 Twitter4J 配置页面上提供的三种方法之一来配置您的身份验证凭据,然后代码示例才能运行。尝试使用 twitter4j.properties 文件、ConfigurationBuilder、系统属性或环境变量对用户进行身份验证。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-07-14
    • 2012-02-09
    • 1970-01-01
    • 2011-05-08
    • 2012-06-02
    • 2020-05-01
    • 2020-09-10
    • 1970-01-01
    相关资源
    最近更新 更多