0

我正在尝试仅使用那里的名称获取朋友的用户 ID。来自 SQl 背景,我认为它就像 [Select] [UID] [From] friend [Where] Name = "friends name".

所以我的查询是

$fql_query_url = 'https://graph.facebook.com/'
    . 'fql?q=SELECT+uid+FROM+friend+WHERE+name=Friends Name'
    . '&access_token=' . $access_token;

我的逻辑有什么错误?

4

1 回答 1

1

您应该使用而不是friendFQL 表来检索您朋友的姓名。这是因为该表仅存储两者之间的关系,而不是有关它们的详细信息。useruidfrienduser

所以你的查询应该如下

SELECT uid 
FROM user
where name = "Name" and uid in (select uid2 from friend where uid1 = me())

由于该name字段不可索引,我们需要user使用uid2from friendtable 过滤表中的用户。

编辑

您的查询需要更改为以下才能工作

$fql_query_url = 'https://graph.facebook.com/fql?'
     . 'q=SELECT+uid+FROM+user+where+name+%3D+%27User+Name%27+'
         . 'and+uid+in+%28select+uid2+from+friend+where+uid1+%3D+me%28%29%29'
         . '&access_token=' . $access_token;
于 2013-07-02T06:57:55.813 回答