0

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.

Community
  • 1
  • 1
mmx73
  • 972
  • 1
  • 8
  • 19
  • BTW I'm also seeing problems with the FQL solution, giving me "Please use the application specific ID instead" which is odd, as they just gave me these IDs I'm querying – Noam Apr 28 '15 at 09:01
  • Have you considered scraping the mobile site instead? https://m.facebook.com/friends – Danny Jun 13 '15 at 17:54

1 Answers1

2

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

andyrandy
  • 72,880
  • 8
  • 113
  • 130
  • I know scraping is not allowed therefor I mentioned that you will make FB mad ;). Anyway, //friends will only give you a result if the friends of the user are using your app. Maybe I just use FQL and hope that this field will be available in graph api in a later version. – mmx73 Nov 12 '14 at 16:16
  • additional you need the user_friends permission with the access_token otherwise you are not seeing this information. Maybe you want to add this in your answer. – mmx73 Nov 12 '14 at 16:44