I'm trying to implement a simple application that uses Twitter kit. The problem is that i'm not able to get the profile picture.Any help would be appreciated.
Thanks
Profile banners allow users to further customize the expressiveness of their profiles. Use POST account/update_profile_banner to upload a profile banner on behalf of a user. Profile banners come in a variety of display-enhanced sizes.
Try either upgrading your browser so it is up to date, or try using a different browser. Your upload problem may be related to the browser or computer you're using. Make sure you click 'Apply. ' Your image won't save until you do.
From the official doc:
You can obtain a user’s most recent profile image from
GET users/show
. Within the user object, you’ll find theprofile_image_url
andprofile_image_url_https
fields. These fields will contain the resized “normal” variant of the user’s uploaded image. This “normal” variant is typically 48x48px.By modifying the URL, you can retrieve other variant sizings such as “bigger”, “mini”, and “original”.
Following the code:
TwitterApiClient twitterApiClient = TwitterCore.getInstance().getApiClient();
twitterApiClient.getAccountService().verifyCredentials(false, false, new Callback<User>() {
@Override
public void success(Result<User> userResult) {
String name = userResult.data.name;
String email = userResult.data.email;
// _normal (48x48px) | _bigger (73x73px) | _mini (24x24px)
String photoUrlNormalSize = userResult.data.profileImageUrl;
String photoUrlBiggerSize = userResult.data.profileImageUrl.replace("_normal", "_bigger");
String photoUrlMiniSize = userResult.data.profileImageUrl.replace("_normal", "_mini");
String photoUrlOriginalSize = userResult.data.profileImageUrl.replace("_normal", "");
}
@Override
public void failure(TwitterException exc) {
Log.d("TwitterKit", "Verify Credentials Failure", exc);
}
});
For further information refer to Twitter API Documentation | Profile Images and Banners
As of Nov 2016. This works. There is a change in the implementation of verify credentials.
Call<User> user = TwitterCore.getInstance().getApiClient().getAccountService().verifyCredentials(false, false);
user.enqueue(new Callback<User>() {
@Override
public void success(Result<User> userResult) {
String name = userResult.data.name;
String email = userResult.data.email;
// _normal (48x48px) | _bigger (73x73px) | _mini (24x24px)
String photoUrlNormalSize = userResult.data.profileImageUrl;
String photoUrlBiggerSize = userResult.data.profileImageUrl.replace("_normal", "_bigger");
String photoUrlMiniSize = userResult.data.profileImageUrl.replace("_normal", "_mini");
String photoUrlOriginalSize = userResult.data.profileImageUrl.replace("_normal", "");
}
@Override
public void failure(TwitterException exc) {
Log.d("TwitterKit", "Verify Credentials Failure", exc);
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With