如何使用Twitter工具包在Android中获取个人资料图片,

前端之家收集整理的这篇文章主要介绍了如何使用Twitter工具包在Android中获取个人资料图片,前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试实现一个使用Twitter工具包的简单应用程序.问题是,我无法获得个人资料图片.任何帮助将不胜感激.

谢谢

解决方法

来自官方文件

You can obtain a user’s most recent profile image from GET users/show. Within the user object,you’ll find the profile_image_url
and profile_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”.

遵循以下代码

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);
    }
});

有关详细信息,请参阅Twitter API Documentation | Profile Images and Banners

原文链接:https://www.f2er.com/android/318441.html

猜你在找的Android相关文章