Main menu
WalkswithMeSocial NetworkingFacebook like and share count of a url

Facebook like and share count of a url

How to get Facebook like and share count of a url using facebook api. Yes its quite simple and easy to get like, share , comment , click count etc using facebook api. In my previous post Custom Social Share Buttons Integration . will help you to create a facebook share button with custom styles, but that integration will loose the facebook share count, that can be achieved by using Facebook like and share count api.

lets check how to implement facebook like and share count of a given url.


https://api.facebook.com/restserver.php?method=links.getStats&urls=[URL]
facebook like and share count

facebook like and share count

Just check how to get these facebook like and share count with facebook api. You just need to pass your url to the api it will return all your data as an XML format just parse it using any of the program like Javascript, PHP,ASP etc.

Here i just give an example with PHP using simple xml parse option.


$url = 'https://www.facebook.com/Walkswithme';
$xml = simplexml_load_file("http://api.facebook.com/restserver.php?method=links.getStats&urls=".$url);
$counts = $xml->link_stat->share_count; //share count
echo "<pre/>";
print_r($xml);

Its quite simple and easy to integrate , it will also help you to show a counter just besides you custom facebook like or share buttons.

Thanks for reading.

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *

 

FacebookTwitterGoogle+RSS