With the introduction of the Facebook Graph API 2.0, access a user’s friends list was removed and limited to just friends who use the same application. However, Facebook added two new APIs to allow retrieval of Friend names (and indirectly a friend count). The two new APIs are
In order to make use of the new end-points (or even just to access the user’s friends list), your application must request the
user_friends permission. This new permission was introduced as part of Graph API 2.0.
The New Endpoints
taggable_friends API retrieves a list of friends that can be tagged by the user in stories. Not all friends will be displayed, but of the ones that appear, the API will return the a encrypted ID that can be used for tagging, their name and profile photo. The use of this end-point requires login review from Facebook.
invitable_friends API is restricted to games and provides similar functionality to
Retrieving Taggable Friends
You can retrieve taggable friends using the following code:
You can retrieve inevitable friends in a similar way if you have a Game application. Just replace the
/taggable_friends in the API call with
Using Encrypted ID to Tag Friends
You can use the encrypted IDs from API call to then tag friends in stories (status updates or actions). You must include the
place attribute as Facebook only allows friends to be tagged at location. However, if you use a
page_id with no address, Facebook hide the location and create a normal status update.
The code above creates the following status update on Facebook: