使用 facebook-android-SDK 获取好友图片

发布于 2024-10-19 11:56:31 字数 205 浏览 5 评论 0 原文

我正在使用朋友的 ID 和姓名

mAsyncRunner.request("me/friends", new FriendRequestListener());

,但我还需要朋友的个人资料照片。 我可以遍历朋友来获取它们,但这是很多请求。

有没有办法在一次请求中获取好友 ID、姓名和照片?

谢谢

I'm getting friends ids and names using

mAsyncRunner.request("me/friends", new FriendRequestListener());

but I also need the friends profile pictures.
I could loop over the friends to get them, but this is many requests.

Is there any way to get friends ids, names AND pictures in one request?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

小情绪 2024-10-26 11:56:31

不幸的是,不是因为朋友列表是 JSON 编码的答案,并且包含所有图片将是一个巨大的响应。
您必须调用 http://graph.facebook.com/ + userid + /picture?type=large (如果您想要小尺寸版本,请省略 ?type=large)为每一位朋友。

Unfortunately not because friends list is a JSON encoded answer and including all pic would be a huge response.
You have to call http://graph.facebook.com/ + userid + /picture?type=large (omit ?type=large if you want small sized version) for every friend.

南…巷孤猫 2024-10-26 11:56:31

你写道:

有没有办法在一次请求中获取好友 ID、姓名和照片?

是的,这是可能的,使用 FQL用户Friend FQL 表:

SELECT uid, name, pic, pic_small, pic_big, FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me())

在您的 Android 应用程序中,您可以像这样进行 FQL 查询:

String query = "SELECT uid, name, pic, pic_small, pic_big FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me())";

Bundle params = new Bundle();
params.putString("method", "fql.query");
params.putString("query", query);
mAsyncFacebookRunner.request(null, params, new CustomRequestListener());

其中 CustomRequestListener() 扩展了 RequestListener 中的脸书安卓 SDK。

这将返回:

  • id
  • 用户名
  • 默认、小和大个人资料图像的 URL 。

当前用户朋友的

You wrote:

Is there any way to get friends ids, names AND pictures in one request?

Yes, it's possible, using FQL and the User and Friend FQL tables:

SELECT uid, name, pic, pic_small, pic_big, FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me())

In your Android app you can make the FQL query like so:

String query = "SELECT uid, name, pic, pic_small, pic_big FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me())";

Bundle params = new Bundle();
params.putString("method", "fql.query");
params.putString("query", query);
mAsyncFacebookRunner.request(null, params, new CustomRequestListener());

where CustomRequestListener() extends RequestListener in the Facebook Android SDK.

This will return:

  • id
  • user name
  • URLs for default, small and big profile images

for the current user's friends.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文