Reputation:
i am trying to show number of likes on my website of my page but i dont want that facebook widget. Please help me - Any API Request that i can use to pull number of likes.
Thanks in advance
Upvotes: 1
Views: 443
Reputation: 3143
Yes, you can do this easily with Facebook Graph API.
There are two options:
if you want to get number of likes of some Page or URL, use this piece of code:
https://api.facebook.com/method/fql.query?query=select%20like_count%20from%20link_stat%20where%20url=%27http://www.facebook.com/facebook/%27&format=json
NOTE that you need to change the part where i wrote URL that's http://www.facebook.com/facebook
The New Graph API provides a minimal pull request code e.g.
http://graph.facebook.com/[Type your Page USERNAME here]?fields=likes
Here replace [Type your page username]
part with username e.g.
http://graph.facebook.com/facebook?fields=likes`
and it will give you an output like:
{
"id": "20531316728",
"likes": 92990262
}
I hope this helps and fulfills your purpose.
Upvotes: 1