0

I just created a simple interface with two EditText fields to give Username and Password to log in with Twitter account. I have correctly added jtwitter.jar file in to my project. Then when I try to run the following code;

    twitter = new Twitter(givenUsername, givenPassword);

try {
    twitter.setStatus("hello");
    Toast.makeText(getApplicationContext(), "login success...", Toast.LENGTH_LONG).show();
} catch (Exception e) {
    System.out.println("Exception caz of setStatus :" + e);
}

it gives me an error;

Updater.run exception: winterwell.jtwitter.TwitterException: 401 Unauthorized http://twitter.com/statuses/friends_timeline.json

I have given Internet permission in my Manifest file.

Please help me to implement my own Android Twitter app.

AnujAroshA
  • 4,623
  • 8
  • 56
  • 99

1 Answers1

0

The 401 error is from Twitter, and it means your app isn't authenticating with them.

I see you're using: twitter = new Twitter(givenUsername, givenPassword); This isn't supported by Twitter! (see the javadoc).

NB: It is supported by some Twitter-like services which support the Twitter API (e.g. Wordpress). But Twitter themselves stopped supporting it quite a while ago.

To authenticate with Twitter, you'll need to use oauth. Have a look at OAuthSignpostClient. There's also help on the JTwitter webpage

Daniel Winterstein
  • 2,418
  • 1
  • 29
  • 41