4

我正在尝试通过我的 Android 应用程序发送直接消息

但我在 LogCat 收到以下错误:

java.lang.IllegalStateException:缺少身份验证凭据。有关详细信息,请参阅http://twitter4j.org/configuration.html

我提到了http://twitter4j.org/en/code-examples.html

//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());
4

1 回答 1

1

正如错误消息所说:

缺少身份验证凭据。

从 Twitter4J代码示例页面:

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

您必须登录才能在 Twitter 上发送直接消息。您需要通过 Twitter4J 配置页面上提供的三种方法之一来配置您的身份验证凭据,然后代码示例才能运行。

  1. 通过 twitter4j.properties
  2. 通过 ConfigurationBuilder
  3. 通过系统属性
于 2012-10-15T23:19:04.460 回答