1

我想允许我的应用程序中的用户按名字搜索他们不是朋友的人。

我知道我可以使用此查询对用户进行公开搜索:

search?q=mark&type=user

这给了我所有用户的名字mark,并且与用户不太相关。

我用它来按名字搜索他们朋友的用户:

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())

我会满足于允许用户使用以下方式搜索他们的朋友的朋友:

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()))

但不幸的是,这会返回以下错误:

{
"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
}

我理解这个错误。看来我将不得不使用公共搜索。

如何公开搜索隶属于大学 XXX 且名称包含“标记”的所有用户?

或者是否有人可以通过与特定用户相关的内容来过滤公共搜索?

4

1 回答 1

0

这似乎有点工作......(它似乎只显示一些朋友或朋友,但我还没弄清楚它是如何过滤它们的)

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))))
于 2012-05-07T01:17:23.683 回答