How to get user information from twitter in android app?

Panache picture Panache · Jun 18, 2011 · Viewed 17.6k times · Source

I am integrating twitter in my android app. I am able to authorize the app for the user. Now, I am looking for the API which gives me logged users information like first name, last name, email, etc. I had done this for facebook with

facebook.request("me");

Now how to get user info from twitter? I am using twitter4j-core-android2.2.3.jar. Plz let me know is there a way to get user info.

Answer

Panache picture Panache · Jun 19, 2011

Finally I got user information.

use the access token you get after

accessToken = twitterConnection.getOAuthAccessToken
    (requestToken,editPinCode.getText().toString());

oHelper.storeAccessToken(accessToken);

Log.i("Access Token:", accessToken.getToken());

Log.i("Access Secret:", accessToken.getTokenSecret());

long userID = accessToken.getUserId();

User user = twitterConnection.showUser(userID);

user.getName();

Thanks.