skip to Main Content

I want to get all of my facebook friends every day and I was searching which is the more efficient way to do it.

My first approach was to create a selenium webdriver script. It opens a web browser, visits /me/friends, scrolls down automatically until the list finishes and then it parses the names. It is working pretty good but it takes some time (approximately 4-5 minutes).

After some search on the graph API, it appears that it isn’t possible to have your complete list.

Another approach is to request from facebook to download all of your data, but facebook sends you an email and you need to wait and download it etc. and still you have to wait.

Final approach was to use a chrome extension (the name is who deleted me) which it worked and it was faster than my approach. I am wondering how this extension worked and one thing that I noticed is that it didn’t found a friend of mine which has passed away. I don’t like a 3rd party extension to have my data and I prefer to do it on my own. So I am wondering is there an endpoint which returns your public friends? or what is the approach of this chrome extension to do that?

Is there any other programming way of fetching your friends? Sure you could use a headless browser and do some requests to the /me/friends and get the responses as it does a web browser when it scrolls down, but it is pretty difficult to understand which ajax calls are the correct ones.

Update:
My approach of scrapping: https://gist.github.com/johndel/cd01a854e8bf36d9d30b44758607cf3d#file-check_friends-rb

It isn’t the best code I can write, just a hack for seeing it done, just replace the sendkeys with your email / password and it will do the trick. My approach gets all of my friends (the chrome extension approach didn’t found a friend of mine, that’s why I think it is hitting another endpoint and it is doing it differently).

2

Answers


  1. Chosen as BEST ANSWER

    I found another url where I can fetch the users and it seems there are a bunch of them and more than one solution. So, a headless and faster approach is this gist:

    https://gist.github.com/johndel/29afec4b159203baf7521cd5a50dbb60 and I guess it can be optimized even further with threads (maybe typhoeus and hydra).


  2. /me/friends is a Graph API endpoint that will only get your a list of friends who authorized your App. It is not possible at all to get friends who did not authorize your App. Everything that WOULD be possible is not allowed on Facebook, because it involves scraping.

    Scraping Terms: https://www.facebook.com/apps/site_scraping_tos_terms.php

    More information: Facebook Graph Api v2.0+ – /me/friends returns empty, or only friends who also use my app

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search