4
votes

I am trying to send direct message through my Android application

But I am getting following error at LogCat:

java.lang.IllegalStateException: Authentication credentials are missing. See http://twitter4j.org/configuration.html for the detail.

I referred to 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());
1

1 Answers

1
votes

As the error message says:

Authentication credentials are missing.

From the Twitter4J Code Examples page:

To run the example codes, you need to have OAuth credentials configured in twitter4j.properties. See Twitter4J - Configuration for the detail.

You must be logged in to send direct messages on Twitter. You need to configure your authentication credentials by one of the three methods given on the Twitter4J Configuration page before the code example will work.

  1. via twitter4j.properties
  2. via ConfigurationBuilder
  3. via System Properties