【问题标题】:How to get user's friends profile photo (avatar) from Facebook如何从 Facebook 获取用户的好友头像(头像)
【发布时间】:2016-12-15 10:50:53
【问题描述】:

我正在开发一个 Android 版本的应用程序,该应用程序使用 Facebook 进行授权和检索用户的朋友列表。

从 SDK v.2.0 开始,获取未安装您的应用的好友列表变得非常困难,但我成功了,现在我需要获取指向好友个人资料图片(头像)的链接。但 Facebook 不希望为尚未安装该应用程序的朋友返回正常 ID。例如,如果朋友安装了应用程序,则 FB 将其 ID 作为数字返回,例如 651651616851,如果没有,则 FB 返回字符串,例如“glkjrgbdjrbgjdrbhgjhLFKBfEFbFkjgnrg”。

如果我使用类似数字的ID来检索照片,它可以工作,但是如果我尝试使用类似字符的ID,则FB返回803错误。我的问题是我如何获得普通ID或如何获得朋友的头像?

【问题讨论】:

  • 检查this。它会帮助你
  • 所以你是用 taggable_friends 或者 invitable_friends 来获取好友列表的?这些端点用于其名称所指示的非常特定的目的;您不得将它们用于任何其他目的。 Facebook 将拒绝您的应用使用审核中的内容。 Facebook 引入这些模仿是有原因的 - 不要试图规避它们。

标签: android facebook facebook-graph-api facebook-android-sdk


【解决方案1】:

这是获取好友图片的API调用,可以指定(最小)宽度和高度:

/me/friends?fields=picture.width(400).height(400)

【讨论】:

    【解决方案2】:

    Please follow the link of facebook sdk about the Track Current Profile.

     FacebookSdk.sdkInitialize(this.getApplicationContext());
        callbackManager = CallbackManager.Factory.create();
    
        ProfileTracker profileTracker = new ProfileTracker() {
            @Override
            protected void onCurrentProfileChanged(
                    Profile oldProfile,
                    Profile currentProfile) {
                // App code
                   Uri uri = currentProfile.getProfilePictureUri(200,200); 
            }
        };
    

    现在您可以从 Uri 下载用户当前个人资料的个人资料图片。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-01-09
      • 1970-01-01
      • 1970-01-01
      • 2016-06-26
      • 1970-01-01
      • 2012-02-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多