gpt4 book ai didi

android - 如何在 Android 的 Twitter 集成中获取用户个人资料图片?

转载 作者:行者123 更新时间:2023-11-30 03:58:02 27 4
gpt4 key购买 nike

你好,我是 android 的新手,试图将 twitter 与我的应用程序集成。用户登录后,我需要获取 Twitter 个人资料名称和个人资料图片。我能够获取个人资料名称,但不能获取个人资料图片。如何获取头像?

最佳答案

你可以通过这种方式获取一些信息:

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;
// ... other infos

// Get the profile pic
// _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);
}
});

来自官方文档:

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”.

关于android - 如何在 Android 的 Twitter 集成中获取用户个人资料图片?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13032161/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com