searching friends using facebook graph api

13,789

Solution 1

You can get the list of friends using the following API call:

Friends: https://graph.facebook.com/me/friends?access_token=...

and then search in the list for the person you are looking for.

Refer to more detailed documentation here: http://developers.facebook.com/docs/api

Solution 2

You can search friend's name like this:

select uid, name, sex 
from user 
where uid in (SELECT uid2 FROM friend WHERE uid1 = me())
and (strpos(lower(name),'TheFriendName')>=0 OR strpos(name,'TheFriendName')>=0)

TheFriendName=Full name or part of the name

Example:

select uid, name, sex 
from user 
where uid in (SELECT uid2 FROM friend WHERE uid1 = me())
and (strpos(lower(name),'Jack')>=0 OR strpos(name,'Jack')>=0)
Share:
13,789
Tim Shi
Author by

Tim Shi

Updated on June 16, 2022

Comments

  • Tim Shi
    Tim Shi almost 2 years

    Does facebook have an api for searching a user's friend?

    Tim

  • Amit Battan
    Amit Battan almost 13 years
    can I apply filter in this API .. means I want search "AMIT" within my friends only. . . . . graph.facebook.com/search?q=Amit&type=user this API search user AMIT but it search publicly but I want to search within friend list only
  • Raptor
    Raptor almost 10 years
    sidenote: FQL will soon be deprecated. Read documentation for more details.
  • Ionut
    Ionut over 6 years
    Agree with @AmitBattan, I didn't found anything in the Facebook docs to do that, which is weird. Well done Facebook, well done...