2

I have to do Login Authentication to post the tweets. I got the Jtwitter.jar and SignPost.jar file from this link. As far as i searched, the xAuth Authendication is more efficient. But i did not get any simple tutorial or piece of code for Login Authendication yet. I found this Article and used this code. thats get NullPointerException.

I created the customer key and Secret key also used the code where got the jar site. That gets Verification Error.

Please Share some idea or steps to follow to verify the username and password of the user?

Edit:

I want to post to from the user's account. what do you prefer to use the Api whether Jtwitter or Oauth? and Tell me How-to or Related Articles ?

Community
  • 1
  • 1
Praveen
  • 90,477
  • 74
  • 177
  • 219

2 Answers2

5

heres is a excellent example to implement OAuth for Twitter in Android

http://github.com/brione/Brion-Learns-OAuth by Brion Emde

heres the video

JTwitter is for basic autentication, Avoid the OAuthocalypse in August 16th twitter aunthentication is about to change http://www.4psmarketing.com/blog/world-cup-2010-delays-twitter-oauthocalypse

Jorgesys
  • 124,308
  • 23
  • 334
  • 268
  • I already Looked it. But there is no option for the user to enter the username and password? – Praveen Jul 16 '10 at 20:03
  • hi Praveen please see the video, i will help you if you have any doubt. – Jorgesys Jul 16 '10 at 20:08
  • Praveen: OAuth never handles usernames or passwords directly. It works by directing the user to a service (i.e. the Twitter login page) to obtain authentication, and then confirming with the service (i.e. the Twitter OAuth service, a URL given to you by the OAuth API) that the user did log in by way of exchanging secret tokens. – Dave Jul 17 '10 at 08:28
  • I have to post the data to the current user's tweet. So tell me what i have to prefer to do this stuff. tell me to use JTwitter or Oauth? – Praveen Jul 17 '10 at 10:29
  • Done. found the Article Here: http://www.androidpeople.com/android-post-status-to-twitter-using-jtwitter-example/ – Praveen Jul 17 '10 at 10:50
  • I got this link in twitter site.http://www.countdowntooauth.com/ Basic Auth going to expire. must need to use the OAuth or XAuth. How to do XAuth in android? – Praveen Jul 17 '10 at 12:35
  • yes Praveen, thats the importance to change from basic to OAuth! – Jorgesys Jul 17 '10 at 19:00
  • hello @Elenasys i was searching for library that can help me with login to twitter in andriod. do you know any kind of library that might be helpful. because i have gone through many tutorials but none of them worked. :( – Aiyaz Parmar Sep 16 '15 at 06:05
2

@Jorgesys - you are wrong to say "JTwitter is for basic authentication". JTwitter supports OAuth, and the example code shows OAuth being used. See the JTwitter documentation

xAuth isn't as good for users because you need to collect user passwords. You'll have to ask Twitter support for permission if you want to use xAuth.

So OAuth may be more work, but it is the best thing to use.

On Android, you'll want to direct the user to an authentication page. The following code should work. You can make things smoother if you can handle callbacks.

// Make an oauth client
// "oob" is for the slightly clunky enter-your-pin method
OAuthSignpostClient oauthClient = new OAuthSignpostClient(MY_OAUTH_KEY, MY_OAUTH_SECRET, "oob");

// open the authorisation page in the user's browser
URI url = client.authorizeUrl();
Intent myIntent = new Intent(Intent.VIEW_ACTION);
myIntent.setData(url);
startActivity(myIntent);

// TODO Get the pin from the user 
String pinCode;

oauthClient.setAuthorizationCode(pinCode);
// Store the authorisation token details for future use
Object accessToken = client.getAccessToken();

// Make a Twitter object
Twitter twitter = new Twitter("my-name", oauthClient);
// Set your status
twitter.setStatus("Messing about in Java");
Daniel Winterstein
  • 2,418
  • 1
  • 29
  • 41