Saturday, March 5, 2022

[FIXED] How to find out the total number of groups created by a user

Issue

i'm playing with these code and it fails:

$fql = "SELECT name FROM group WHERE gid IN (SELECT name FROM group WHERE version=1) AND creator=me()";
$ret_obj = $facebook->api(array(
     'method' => 'fql.query',
     'query' => $fql,
));
echo count($ret_obj["name"]);

does anyone knows how to count() the no. of groups a person has created. Thanks i'm using PHP-SDK.


Solution

Seems like group table has only 1 field gid as indexable which makes it impossible to filter user groups in FQL. Possible bug.

What you can do is make a graph API call to:

https://graph.facebook.com/me/groups?fields=name,owner  

and then filter results by owner.id and count them.

hope this helps



Answered By - Anatoly Lubarsky

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.