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).