Need to get the name and picture of mutual friends without using JS.
Found FQL query below for mutual friends:
"SELECT uid1 FROM friend WHERE uid2=[targetID] AND uid1 IN (SELECT uid2 FROM friend WHERE uid1=[sourceID])"
Is there a way that instead of returning just the uid1
I can get the name and picture of the person?
EDIT ----------- Think I found it.
"SELECT first_name, last_name, pic_small FROM user WHERE uid IN(SELECT uid1 FROM friend WHERE uid2=['targetID'] AND uid1 IN (SELECT uid2 FROM friend WHERE uid1=['sourceID'])) "
You can get mutual friends with the Graph API:
https://graph.facebook.com/me/mutualfriends/FRIEND_ID
You can read more about it in the User object under mutualfriends: https://developers.facebook.com/docs/reference/api/user/
To further add:
To get the pictures as well: https://graph.facebook.com/me/mutualfriends/FRIEND_ID/?fields=id,name,picture&access_token=ACCESS_TOKEN
SELECT uid, first_name, last_name, pic_small
FROM user
WHERE uid IN (
SELECT uid2
FROM friend
WHERE uid1 = ['sourceID']
)
AND uid IN (
SELECT uid2
FROM friend
WHERE uid1 = ['targetID']
)
This will find any user (A), that both the source user (B) and target user (C), are friends with. Not necessarily the other way around; A being friends with B and C.
If the friend-table truly is mirrored, (ie for every row (x,y), there is also row (y,x)) this distinction would not matter.
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.