Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get only the total_count of friends - facebook-graph-api

me?fields=friends fetches

{
  "friends": {
    ...
    "summary": {
      "total_count": 72
    }
  },
  ...
}

I just want total_count, but it seems it isn't a valid sub-field I can put in the query

me?fields=friends{summary} or me?fields=friends{total_count} doesn't work.

Not an absolute necessity, just curious why not or whether it's possible?

like image 997
laggingreflex Avatar asked Dec 07 '25 19:12

laggingreflex


1 Answers

Field expansion only works on the fields of an object.

So if the object is of type user, the fields that can be expanded are listed at https://developers.facebook.com/docs/graph-api/reference/v2.1/user

Example

me?fields=friends{name,link}

If you are trying to decrease the data returned for performance, you can try using the limit to ensure that no friends are returned (the data array is empty) while still obtaining the summary section

me?fields=friends.limit(0)

like image 54
phwd Avatar answered Dec 11 '25 14:12

phwd