Question

I`m working on a php application to create a list of my Facebook friends who play Castleville. I succesfully setup my project to connect to Facebook, and execute a FQL query to retrieve all my facebook friends:

// other stuff, init, etc...

$fql =
"SELECT uid, name, pic_square
FROM user
WHERE uid IN
(SELECT uid2 FROM friend WHERE uid1 = me())";

$param = array(
        'method'    => 'fql.query',
        'query'     => $fql,
        'callback'  => ''
    );

//  query facebook
$fqlResult = $facebook->api($param);

//  parse results
foreach ($fqlResult as $values) {
   // process values 
}

...

Castleville has app_id = 107040076067341

I would like to know how to query the application table to achieve the desired result.

Any help would be appreciated.

...

...

LATER EDIT: (success)

Thank you for the help, it was really useful. I changed the code to retrieve entries from each of my friends' stream and check if the app_id was Castleville's. For each of my friends, I ran the following FQL query:

$fql_select_stream =
"SELECT attribution
FROM stream
WHERE source_id = " . $values['uid'] . " and app_id = " . CASTLEVILLE_APP_ID . " limit 1";

// $values['uid'] is the facebook user ID for the friend

$res = $facebook->api(array(
                'method'    => 'fql.query',
                'query'     => $fql_select_stream,
                'callback'  => ''));

if $res is not empty... we have an active Castleville player!

Was it helpful?

Solution

You can't see if a user's friends use a specific app unless you're making the API call on behalf of that same app If this is your own app, and you just mentioned Castleville as an example, the way to do what you're asking is explained in my answer here: http://facebook.stackoverflow.com/a/7957310/21062

Aso relevant: Is it Possible to FQL list of friends who own specific phone ?(query from wallpost source) - where someone wanted to know how to see which of a user's friends use certain phones - i suggested they examine the user's news feed and see which apps made the post. In your case, you could check if any of the user's friends have posted content from Castleville onto their timeline

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top