ksol
ksol

Reputation: 12265

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 :

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.

Upvotes: 3

Views: 4239

Answers (2)

Igy
Igy

Reputation: 43816

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

Upvotes: -1

Alexander Nenkov
Alexander Nenkov

Reputation: 2910

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

Upvotes: 7

Related Questions