How to get only friends with profile photos uploaded, and ignore those users with the default silhouette?

試著忘記壹切 提交于 2019-12-31 03:56:06

问题


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?


回答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.




回答2:


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.



来源:https://stackoverflow.com/questions/10827962/how-to-get-only-friends-with-profile-photos-uploaded-and-ignore-those-users-wit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!