1

I cannot figure a way get friends only with profile photos. I could use multi-query to check whether every friend has a photo, but that would incur heavy traffic.

Are there any alternatives?

Igy
  • 43,710
  • 8
  • 89
  • 115
Gajus
  • 69,002
  • 70
  • 275
  • 438
  • Could you define what would be a friend without a photo? Do you mean the photo for Test Users display? – phwd May 31 '12 at 05:58
  • This is a friend without a photo https://graph.facebook.com/37005951/picture?type=large – Gajus May 31 '12 at 06:05
  • May be all non-photos have only this image `https://fbcdn-profile-a.akamaihd.net/static-ak/rsrc.php/v2/yL/r/HsTZSDw4avx.gif` . You can check if url of picture is this. – Jashwant May 31 '12 at 07:11
  • The problem with this approach is that I would still need to make `2x` requests. – Gajus May 31 '12 at 10:56
  • Just tried using this approach, though it is not an option. It takes 10 seconds to check data with 500 friends. – Gajus Jun 02 '12 at 04:10
  • Hi, I have the same problem to solve, did you managed to find a solution? Thanks in advance. – luben Nov 19 '12 at 08:34
  • @Lyuben Just added the answer. – Gajus Nov 19 '12 at 10:01

2 Answers2

1

This can be achieved with a simple FQL.

SELECT uid, name, pic_small FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) AND pic_small != 'https://fbcdn-profile-a.akamaihd.net/static-ak/rsrc.php/v1/yP/r/FdhqUFlRalU.jpg'

The seb-query will get all yours friend uids. The other query will match does uids with the profile data check if the pic_small is referring to what Facebook uses as a placeholder.

You can quickly test it here.

Gajus
  • 69,002
  • 70
  • 275
  • 438
1

Although Gajus’ suggested query might work right now, it’ll break once Facebook changes the URL of the default picture on their CDN. (Might happen, might not happen.)

So I’d suggest this for improvement:

The profile_pic table has a field called is_silhouette, which is a boolean for whether the user has their own profile picture set or not.

So to get only those of your friends, that have a profile picture set, you can use

SELECT uid, name FROM user WHERE uid IN
  (SELECT id FROM profile_pic WHERE
    id IN (SELECT uid1 FROM friend WHERE uid2 = me() )
    AND NOT is_silhouette
  )

–> Try this query in the Graph API Explorer.

CBroe
  • 91,630
  • 14
  • 92
  • 150