One of the joys of being a programmer is being able to solve problems that cannot be solved any other way or at least would be difficult or impractical to solve. I had one such episode recently. I noticed that my friends count on Facebook had decreased. I had no idea who was missing but out of mere curiosity, I wanted to know. It’s not that losing friends on Facebook weighs heavily on me; I just like knowing things.
So the first thing that comes to my mind is, “I’ll just build an app to track friends on Facebook”. So to start my exploration, I fired up Facebook’s Graph API Explorer to test out the API for getting a user’s list of friends. I enter “me/friends” as I was used to getting a listing of my friends. It returned a result showing 5 of my friends and a count of my total number of friends and a pagination cursor.
I then attempted to get the next page of results, but it didn’t return any data. Not sure I was doing the right thing, I experimented with various combinations of options like trying to set a higher limit for the number of results returned per page. The data was still limited to the same 5 friends.
At the back of my mind, I had remembered hearing about Facebook limiting access to certain APIs and clamping down on apps that do what I am trying to do, but I wasn’t sure what had changed over the years. I googled the problem and found an article about Facebook shutting down the API to access a user’s friends data to apps.
I went back to look at the documentation page to see if I could find some more information about it but found nothing. I then went back to the Graph Explorer and starting paying attention to a label called “Debug Message” that when clicked revealed this message:
Only friends who installed this app are returned in API v2.0 and higher. total_count in summary represents the total number of friends, including those who haven’t installed the app.
So that was the problem. If I understand it correctly, Facebook is restricting the data to people who’ve actually installed the app accessing the API which in this case would be the Graph Explorer. The 5 friends returned by my search are mostly developers so that makes sense.
This is a bit unfortunate for me but it’s hard to argue that it isn’t better for users in general. People value their privacy and this is one way Facebook is protecting it. Additionally, figuring out who has unfriended you is not something that Facebook would like people to know. This is the kind of information that may cause friction between people and Facebook is all about fostering connections. It’s for similar reasons we will never see the much-requested “dislike” button.
So it appears that for now, I’ll have to put this mission on hold. A thought came to my mind that if the Facebook website itself can access all my friends then maybe there should be some hidden way to access the data. That is likely to be a major challenge but it’s through challenges that we learn and grow, no? We shall see how it goes.