FQL Friend's groups

1.9k views Asked by At

I see that I can access a friend's groups via the Graph API:

https://graph.facebook.com/11111111/groups

... but how do I access it via FQL? (I am searching the documentation extensively before asking these questions, sorry if I'm asking an obvious one).

2

There are 2 answers

5
Yaron U. On

if you want to get the groups of user with the id 1111111

you can write this query:

select gid, name from group 
      where gid in (select gid from group_member where uid = 1111111)

don't forget you need to have the friends_groups permission in order to get this data

the documentation for those tables can be found here:

http://developers.facebook.com/docs/reference/fql/group_member/

http://developers.facebook.com/docs/reference/fql/group/

0
LGG On

Yeah. I tried it did not work with FQL . But you can use the following code to get it via graph api

function get_groups($facebook)
    {
        require_once 'config.php';
         global $facebook; 
         $groups = $facebook->api('/me/groups');
        var_dump($groups);
        return $groups;
    }

The config file has the following :

<?php
    require_once("facebook.php");

    $app_id = "";//put the app id 
    $app_secret = "";//put app secret code inside " "

    $facebook = new Facebook(array(
        'appId' => $app_id,
        'secret' => $app_secret,
        'cookie' => true
    ));

    if(is_null($facebook->getUser()))
    {
        header("Location:{$facebook->getLoginUrl(array('req_perms' => 'user_status,publish_stream,user_photos'))}");//include the permission you want here
        exit;
    }
?>