tonejac
tonejac

Reputation: 1103

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?

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 uid2=target_uid'
},
    function(response) {
        console.log(response);
    }
}

Upvotes: 0

Views: 1511

Answers (1)

Ryan Gibbons
Ryan Gibbons

Reputation: 3601

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*}

Upvotes: 1

Related Questions