0

I would like to build an app that tells user how many of his friends like a particular facebook page. Let's say the name of page is Machester United. And I have 20 friends who like that page.

How can I do that? Should I use facebook graphAPI? Are there any other ways>

I am very new to this. Can you give me some key concepts/things that I should look into?

Aidis
  • 1,272
  • 4
  • 14
  • 31
  • The OP has another question than the one which is marked as duplicate, respectively all the solutions which are outlines in the "duplicate" are not applicable for his use case! – Tobi Jul 30 '14 at 06:30

1 Answers1

2

I think the Social Context API might be the right thing for you, if you're mainly interested in the number of friends which like a certain Facebook Page.

See https://developers.facebook.com/docs/facebook-login/social-context/v2.0

Use

GET /cocacola?fields=context.fields(friends_who_like)

to see which/how many of your friends like the CocaCola Page.

The result will look like

{
  "context": {
    "friends_who_like": {
      "data": [
        {
          "id": "123456789", 
          "name": "Firstname Lastname"
        }
      ], 
      "paging": {
        "cursors": {
          "before": "ODQ5MDkwMjQ2", 
          "after": "ODQ5MDkwMjQ2"
        }
      }, 
      "summary": {
        "social_sentence": "4 of your friends like this.", 
        "total_count": 4
      }
    }
  }, 
  "id": "40796308305"
}

The context.summary.total_count field will contain the number of friends which like the Page.

Try it here: https://developers.facebook.com/tools/explorer?method=GET&path=cocacola%3Ffields%3Dcontext.fields(friends_who_like)&version=v2.0

Keep in mind that

In order for a person to be identifiably returned in a context edge, they must have:

  • Logged into the app.
  • Granted the user_friends permission.
  • Granted the appropriate content permission in order to see the action. For example, to appear in the friends_who_like context edge, each friend has to have granted the app the user_likes permission.
Tobi
  • 31,405
  • 8
  • 58
  • 90