How to get user information from twitter in android app?
Solution 1
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.
Solution 2
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
Solution 3
Twitter.getApiClient(session).getAccountService().verifyCredentials(true, false).enqueue(new Callback<User>()
{
@Override
public void success(Result<User> userResult)
{
try
{
User user = userResult.data;
// twitterImage = user.profileImageUrl;
} catch (Exception e)
{
e.printStackTrace();
}
}
@Override
public void failure(TwitterException e)
{
}
});
Solution 4
You cannot get Email from the twitter OAuth unless or untill your app is whitelisted. For more Info Email ID from Twitter
![Panache](https://i.stack.imgur.com/mIM2Y.png?s=256&g=1)
Comments
-
Panache about 2 years
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.
-
acoustic over 11 yearsdon't know what is "editPinCode", don't know what's "oHelper", but why are so many up vote?
-
Rohit almost 11 yearsHow to get email id ?
-
pavan kvch over 7 yearsIt works perfect , even some tutorial websites dont match your answer, thanks
-
D.J over 7 yearsI am getting error verifyCredential() to AccountService can not applied.
-
D.J over 7 yearsI am not getting email from this.All things I am getting except email.
-
D.J over 7 yearsI am not getting email id and mobile number.
-
Devil10 over 6 yearsi think fabric no more support twitter login due to which this account service code gives error. i also geting error and now confused how to do this .