Facebook API: how to get the number of group members

I am working on an fb application using a PHP client and FQL. Files like fb api do not support this. You can get the maximum number of random 500 members with FQL. But when a group has more than 500 members, there is no way to get the total number of participants. I only need a number that does not care about the details of the participant.

Can anybody help me?

+3
source share
5 answers

You can use the resulting parameter, which will return the value of total_count.

/v2.11/{GROUP_ID}?fields=members.limit(0).summary(true)

It also works when searching for groups:

/v2.11/search?q=stackoverflow&type=group&fields=id,name,members.limit(0).summary(true)

{
    "data": [
        {
            "id": "667082816766625",
            "name": "Web Development Insiders",
            "members": {
                "data": [
                ],
                "summary": {
                    "total_count": 2087
                }
            }
        },
        {
            "id": "319262381492750",
            "name": "WEB Developers India",
            "members": {
                "data": [
                ],
                "summary": {
                    "total_count": 10240
                }
            }
        }...
    ]
}
+1
source

, , , -. , , api, 500- . 450 200, 450-500.

, :

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

+3

api 2.0 sdk 4.0

$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;

        }
+3

:

https://graph.facebook.com/v2.11/{group-id}/members?limit=1500&access_token={token}

( {group-id} {token} ).

:

{
    "data": [
        {
            "name": "Foo bar",
            "id": "123456",
            "administrator": false
        },
        ...
    ],
    "paging": {
        "cursors": {
            "before": "QVFIUkwzT3FKY0JSS2hENU1NUlZAocm9GelJMcUE3S1cxWWZAPYWx1cUQxcXFHQUNGLUJnWnZAHa0tIdmpMT0U5ZAjRBLUY5Q2ZAGbmwwVTNoSHhLc1BCc2dvVTF3",
            "after": "QVFIUkFoU3lYR2tXc09adkg5OGhlbHRWRk1GYkZAzQU1DalRSY05zOVl5aE1tcjRMS3lXLURaVWNMOGZArWTVxS2hPQUVGVWxhbXZAyZA0p3azVKM2hBSEp3YlpR"
        }
    },
    "next": "https://graph.facebook.com/v2.11/123928391023981/members?access_token=EAACEdEose0cBALBDrdgLyVOjzW4mz6G3d3Yj1fTGYqygVgYq0JCDZAi0zYsY90pSSQ9hQZCn3TdwfXIAiyoXH5oUYcA4hOcCI9jztkkUhbBv9tEQ3ZBEEuHpmkm3kmgvk1HNq5mo6BM0hz8XkOLVh3twIdz83KhB9SkqxuxHeFD9GWsQqjys6XTuL2315QZD&pretty=0&limit= 1500&after=QVFIUkFoU3lYR2tXc08adkg5OGhlbHRWYk1GYkZAzQU1DalRSY05zOVl5aQ1tcjRMS3lXLURaVWNMOGZArWTVxS2hPQUVGVWxhbXZAyZA0p3azVKM1hBSEp3YlpR"
}

:

  • count 0.
  • data count.
  • next, URL-, next, 2. , count .

, , . HTML- , .

2017.10.19: API Facebook 345 , Facebook : Please reduce the amount of data you're asking for, then retry your request. 1997 . , limit 1500, .

2018.01.26:. , : fooobar.com/questions/1783497/...

2018.01.31:. 90 Graph API v2.12 . : API docs/v2.12 /90

+1

FQL group_member, :

SELECT uid FROM group_member WHERE gid = <group_id> limit 500 offset 500

: / Facebook ( 500+)?

0

Source: https://habr.com/ru/post/1783497/


All Articles