TheBestBigAl
TheBestBigAl

Reputation: 1230

Is it possible to access a users groups of friends on Facebook using Facebook graph?

By which I mean when people can make sub lists of friends (i.e. work friends, family, close friends).

Is it possible to access these, as I would like my app to let the user target specific groups of friends to send messages to without having to manually choose each person?

Any searches for 'facebook groups', 'facebook friends groups' or 'friends list' turns up info on how to access the main friends list - which I can already do.

Has anyone managed to do this before? On the one hand I think it could be prohibited due to privacy issues, on the other hand I would think Facebook would prefer that users could message groups of friends in apps.

Upvotes: 1

Views: 2162

Answers (1)

Lix
Lix

Reputation: 47966

You can most certainly get at this data. There is a specific permission called user_friendlists. You'll have to request that permission from your users and once you have it, all you have to do is query this Graph end point -

https://graph.facebook.com/USER_ID/friendlists

It'll return data similar to this -

{
  "data": [
    {
      "id": "XXX", 
      "name": "Close Friends", 
      "list_type": "close_friends"
    }, 
    {
      "id": "YYY", 
      "name": "♥", 
      "list_type": "user_created"
    }, 
    {
      "id": "ZZZ", 
      "name": "Offline", 
      "list_type": "user_created"
    }, 
    {
      "id": "AAA", 
      "name": "The Office", 
      "list_type": "work"
    }, 
    {
      "id": "BBB", 
      "name": "Acquaintances", 
      "list_type": "acquaintances"
    }, 
    ...

As you can see, there are both types of friend lists here. Automatically generated ones such as

  • Close Friends
  • Acquaintances

And some custom ones that I manually created -

  • Offline
  • The Office

To get at the actual friends listed within these lists, you use the /members end point.

https://graph.facebook.com/USER_ID/FRIENDLIST_ID/members

This is only the read permission, you'll need the additional manage_friendlists to be able to create/edit those lists.

Upvotes: 5

Related Questions