How can I get the user name, email, location, avatar, etc., of an authenticated user of Twitter in Android via the API?
I wrote the code below, but it always returns null
at twitter.showUser(twitter.getId());
public User getUserInfo(Object accessToken)
{
ConfigurationBuilder configurationBuilder = new ConfigurationBuilder();
configurationBuilder.setOAuthConsumerKey(mConsumer.getConsumerKey());
configurationBuilder.setOAuthConsumerSecret(mConsumer.getConsumerSecret());
twitter4j.Twitter twitter = new TwitterFactory(configurationBuilder.build()).getInstance();
try
{
twitter.setOAuthAccessToken((AccessToken) accessToken);
return twitter.showUser(twitter.getId());
}
catch (Exception e)
{
e.printStackTrace();
return null;
}
I found another question here. People said that unable to retrieve email address of authenticated user of Twitter via api. So, How about other information such as fullname, avatar, phone number (if have),...?