I used to get the number of likes for my webpage from facebook with:
http://api.facebook.com/restserver.php?method=links.getStats&format=json&urls=www.example.com
But this doesn’t work anymore.
I tried:
https://graph.facebook.com/fql?q=SELECT%20total_count%20FROM%20link_stat%20WHERE%20url=%22www.example.com%22
But this doesn’t work either.
I tried:
http://graph.facebook.com/?ids=http%3a%2f%2fwww.example.com
But this gives me only the share_count, not the number of likes.
I found this: https://developers.facebook.com/docs/graph-api/reference/v2.7/object/likes
POST graph.facebook.com/v2.7/{object-id}/likes HTTP/1.1
But I got no idea what the {object-id} is or where I can get it. And I don’t know if I need any access-credentials to access the information.
Anyone got a small example what http-requests I need now to get the likes of my webpage please?
2
Answers
First You need the Id for the page. You can to use the next page. http://findmyfbid.com/ There is you put the link of facebook page that You need for example.
https://www.facebook.com/BooStore1
and the result is:
149955492088239
Now you’re going to the api graph of facebook and you need yo use the field “fan_count”
This would look like
Results:
Note: first step is optional, You can to use the name in facebook page url that you need.
receive the number of shares/comments and object-id
save shares/comments count
save fb object-id of url
get likes count with (max limit is 1000, then you can use paging):
UPD 2016-08-22
I found a solution that allows you to get the number of likes/reposts/comments in one step: