简体   繁体   中英

Get Facebook profile pictures album

I'm trying to retrieve all profile pictures for a user in facebook. So far, I've found that I have to look in "me/albums", and the album I want is the only one of type: 'profile' .

I also found that I cannot filter on the type . So it seems to me the only way is retrieving all albums, then searching for the one I want. But let's say my user have tons of albums, and the first response from facebook does not contain the album I want. I then have to make another request to get the next page.

My questions are :

  • Is there really no way to filter on the type ?
  • Can I make assumptions about "where" (page wise) the profile pictures album will be?

Currently we are retrieving all (max 300) albums and looking on them after, but it takes too much time. Hence the questions, we need to optimize this part. For what it's worth, it's a rails 3 app with Koala handling facebook interactions.

You can use

https://graph.facebook.com/me/fql?q=select+aid+from+album+where+owner=me()+and+type="profile"&access_token=...

update

This will return you directly only the profile pictures:

https://graph.facebook.com/me/fql?q=select+pid,src_small+from+photo+where+aid+in(select+aid+from+album+where+owner=me()+and+type="profile")&access_token=...

No, there's no way to retrieve the Profile Photos albums specifically in Graph API; but you'll get the current profile pic easily as its returned in the user's basic information.

Why not just retrieve all album names in one call ( /me/albums?fields=name&limit=500 ) and loop through them in code? It can't take that long really, can it?

{edit} Alexander's solution should work too, I haven't checked it though

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM