How can I get the facebook friends_count of a user profile via graph API 2.2?

614 views Asked by At

In most of the profiles the count of the actual friends is public, but there seems to be no obvious way to get this figure via graph api.

If you access via /user.id/friends?access_token= will get the whole friends list but only if the friends are using your facebook app too. (see Get facebook friends with Graph API v.2.0 ). But I will not need the friends, I just need the count.

There is a possibilty via FQL:

facebook.com/fql?q=SELECT friend_count FROM user WHERE username="<username>" 

but this leads to nowhere because in the future FQL is not supported anymore.

The 3rd possibilty would be to scrape the whole page. But this will make facebook mad and is not very efficient (a fb site has ~400kb).

Does anyone know another possiblity/trick to get the friends_count of any user on facebook with this attribute public ?

Thanks for any suggestions.

1

There are 1 answers

2
andyrandy On BEST ANSWER

You cannot get the friend count of any user, you can only get that value from the user who is authorized right now:

/me/friends

There will be a summary.total_count field in the result.

You need the user_friends permission with the access token as well.

Btw, scraping is not allowed: https://www.facebook.com/apps/site_scraping_tos_terms.php