Nebide Yildiz
Nebide Yildiz

Reputation: 4131

How to retrieve a friendlist's members count with Graph Api?

I want to retrieve a friendlist's members count. But Get("me/friendlists") returns only friendlist's id,name and list_type.

_currentFbClient = new FacebookClient(_userToken);
_me = _currentFbClient.Get("me/friendlists");

Any help will be appreciated.

Upvotes: 0

Views: 1031

Answers (1)

Igy
Igy

Reputation: 43816

There isn't a count available, you've to pull the members list of each group and count them yourself unfortunately

You can get the members of a list with a GET to /FRIEND_LIST_ID/members

Once you have the friend list IDs, put them into a string, comma separated, and you can get a full list of members of all the lists in a single call by calling

_currentFbClient.Get("/?fields=members&ids=$STRING_CONTAINING_IDS_OF_LISTS")

The response will be something like this:

{
 "LIST_ID_1": {
    "members": {
      "data": [
        {     {
          "id": "USER ID", 
          "name": "NAME"
        }, 
        // Other friends on list
     }
  },
  "LIST_ID_2:{
// etc etc

Upvotes: 2

Related Questions