FBML to get the share count of a link?
I need to get the number of likes for a given url.how to do it? also can i get the to开发者_JAVA技巧tal fancounts of a fb page?
Address
http://graph.facebook.com/?id=http://facebook.com
returns:
{"id": "http://facebook.com","shares": 54290530,"comments": 1244}
So to change id parametr for your URL and get your shares count via jQuery use:
jQuery(document).ready(function($){
$.getJSON(
"http://graph.facebook.com",
{ id : "http://facebook.com" }, //here should be your URL
function(json){
//var data = jQuery.parseJSON();
alert( json.shares );
}
);
});
Use Facebook's API. Just add the URL's you are interested in to the end of of this URL:
http://api.facebook.com/restserver.php?method=links.getStats&urls=
example:
http://api.facebook.com/restserver.php?method=links.getStats&urls=stackoverflow.com,serverfault.com
I think the fancount is just the "like" count of the URL for the FB page.
Source, with PHP code for parsing the output: Get likes on urls from Facebook
FQL link_stat
would be a nice alternative to rest API (facebook is in process of deprecating the REST API)
https://developers.facebook.com/docs/reference/fql/link_stat/
精彩评论