Making friends with facebook-android-SDK

I get the names and names of friends using

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

but I also need friends profile pictures. I could sort out friends to get them, but that’s a lot of requests.

Is there a way to find friends, names and images in a single query?

thanks

+4
source share
2 answers

You wrote:

Is there a way to find friends, names and images in a single query?

Yes, perhaps using FQL and 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 application, you can make the FQL query as follows:

 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 Android Android SDK.

This will return:

  • ID
  • Username
  • URLs for default images, small and large profiles

for current friends of the user.

+1
source

Unfortunately, not because the friends list is a JSON encoded response, and including the whole pic will be a huge answer.
You should call http://graph.facebook.com/ + userid + /picture?type=large (omit ?type=large if you want a small version) for each friend.

+7
source

Source: https://habr.com/ru/post/1341685/


All Articles