0

I am trying to send the Direct messages from my Android app. For that I have Googled and found the following solution from the links . In that Twitter4j I have found the code snippet. I have tried the same in my Android app also, but got the issue:

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

Please help me to come out of this issue.

Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880
RAJESH
  • 231
  • 1
  • 5
  • 19

1 Answers1

0

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 can't send direct messages on Twitter unless you're logged in (unlike some other features, like reading a random user's status updates). You'll need to configure your authentication credentials by one of the three methods given on the Twitter4J Configuration page before the code example will work.

Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880
  • i have got the following Exception while trying to send the direct message to my followers . 10-11 11:21:45.930: W/System.err(11946): 403:The request is understood, but it has been refused. An accompanying error message will explain why. This code is used when requests are being denied due to update limits (https://support.twitter.com/articles/15364-about-twitter-limits-update-api-dm-and-following). 10-11 11:21:45.930: W/System.err(11946): error - You cannot send messages to users who are not following you. – RAJESH Oct 11 '12 at 05:58