1

I would like to allow users in my app to search for people they are not friends with by name.

I understand I can do a public search for users using this query:

search?q=mark&type=user

This gives me ALL users with the name mark and isn't very relevant to the user.

I use this to search users they are friends with by name:

fql?q=
    SELECT uid, name, pic_square 
    FROM user 
    WHERE strpos(lower(name),lower('mark')) >=0 AND 
        uid IN (SELECT uid2 FROM friend WHERE uid1 = me())

I'd be content allowing users to search their friends of friends using something like this:

fql?q=
    SELECT uid, name, pic_square 
    FROM user 
    WHERE strpos(lower(name),lower('mark')) >=0 AND 
        uid IN (SELECT uid2 
                FROM friend 
                WHERE uid1 IN (SELECT uid2 
                               FROM friend 
                               WHERE uid1 = me()))

but unfortunately that returns the following error:

{
"message": "(#604) Can't lookup all friends of #####. 
    Can only lookup for the logged in user or the logged in user's friends that 
    are users of your app.", 
"type": "OAuthException", 
"code": 604
}

I understand this error. It looks like I'm going to have to use the public search.

How could I do a public search for all users affiliated with university XXX with a name containing 'mark'?

or does anyone have any alternatives to filter a public search by something relevant to a specific user?

Greg
  • 8,574
  • 21
  • 67
  • 109

1 Answers1

0

This seems to kinda work... (it seems so only show some friends or friends, I haven't figured out how it's filtering them though)

fql?q=
    SELECT uid, name 
    FROM user 
    WHERE strpos(lower(name),lower('mark')) >=0 AND 
        (uid IN (SELECT uid2 
                FROM friend 
                WHERE uid1 = me()) OR 
        (uid IN (SELECT uid2 
                FROM friend 
                WHERE uid1 IN (SELECT uid 
                                FROM user 
                                WHERE uid IN (SELECT uid2 
                                                FROM friend 
                                                WHERE uid1 = me()) AND 
                                                    is_app_user=1))))
Greg
  • 8,574
  • 21
  • 67
  • 109