Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get user information from twitter in android app?

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.

like image 461
Panache Avatar asked Jun 18 '11 12:06

Panache


2 Answers

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.

like image 99
Panache Avatar answered Oct 05 '22 23:10

Panache


There are a few tutorials here that can help you get an app running with twitter..

if you just need to retrieve info for a specific user, you can look here (includes source code):

Basic Adroid Twitter Integration

If you want to interact with twitter (e.g. post updates etc) then you will need to setup OAuth connection:

Android and Twitter integratin using OAuth

like image 25
rhinds Avatar answered Oct 06 '22 00:10

rhinds