开发者

Facebook fql.query Syntax

I'm trying to properly understand the syntax for Facebook's fql.query. The context for this query is to get all the mutual friends between two users. Using an example of "user1 = dusty24" and "user2 = april1991" what would the values for the following vars be?

  • uid1
  • uid2
  • source_uid
  • target_uid

It's pretty safe to assume that 'uid1 = dusty24' and 'uid2 = april1991' but what the heck are the values for 'source_uid' and 'target_uid'?

FB.api(
{
    method: 'fql.query',
    query: 'SELECT uid1 FROM friend WHERE uid1 IN (SELECT uid2 FROM friend WHERE uid1=source_uid) AND uid开发者_开发问答2=target_uid'
},
    function(response) {
        console.log(response);
    }
}


I took a quick read through the documentation, it tells us uid1 is the user id of the first user of the pair and uid2 is the second user of the pair. These are fields from the table. You don't change these in the query. You would end up with source_uid and target_uid be the user ID's of each of those people.

Assuming your query works correctly. You would end up looking something like this. Note: you would need to get the user id of your two users before hand.

SELECT uid1 FROM friend 
WHERE uid1 IN 
( SELECT uid2 FROM friend WHERE uid1={*dusty24 uid*} ) 
AND uid2={*april1991 uid*}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜