Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook API: How to get count of group members

Im working on fb app using PHP client and FQL.Looks like that fb api doesnt support this. You can get max random 500 members with FQL. But when group has more than 500 members there is no way how to get total count of members. I need only number dont care about member details.

Anyone can help me please?

like image 707
Petr Velký Avatar asked Dec 14 '25 10:12

Petr Velký


2 Answers

I have actually found that you cannot, it is by design apparently. I wanted to know this myself about a month ago, and found that no matter what parameters you pass in to the graph api, you can not get past the 500th member. Even if you tell it to start at number 450 and give you 200, it will give you only 450-500.

Here's me asking, and the unfortunate answer:

http://forum.developers.facebook.net/viewtopic.php?id=82134

like image 149
Tesserex Avatar answered Dec 17 '25 00:12

Tesserex


you can use graph api 2.0 and sdk 4.0

you can use below code

$url1= "https://graph.facebook.com/".$gid."/members?limit=10000&access_token=".$_SESSION['fb_token'];





if(!extension_loaded('curl') && !@dl('curl_php5.so'))
    {
        return "";
    }



    $parsedUrl = parse_url($url1);
    $ch = curl_init();
    $options = array(
        CURLOPT_URL => $url1,
        CURLOPT_RETURNTRANSFER => 1,
        CURLOPT_TIMEOUT => 10,
        CURLOPT_HTTPHEADER => array("Host: " . $parsedUrl['host']),
        CURLOPT_SSL_VERIFYHOST => 0,
        CURLOPT_SSL_VERIFYPEER => false
    );
    curl_setopt_array($ch, $options);
    $response_count = @curl_exec($ch);
    $json_count = json_decode($response_count); 

        foreach ($json_count as $item_count)
        { 


                    $cnt=count($item_count);
                    break;

        }
like image 35
rocoder Avatar answered Dec 16 '25 23:12

rocoder



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!