How to get facebook like, share and comment count using PHP
In this totorial i will show you how to get facebook like, share and comment count using php in Here’s the final code that goes into your website project. Copy this code and test your server. You may also like How to Make Auto Post in Facebook Using PHP
HTML Code
<html>
<body>
<form method="post" action="">
<p>Enter URL</p>
<input type="text" name="url">
<input type="submit" name="submit">
</form>
</body>
</html>
PHP Code
<?php
if(isset($_POST['submit']))
{
$url = $_POST['url'];
$rest_url = "http://api.facebook.com/restserver.php?format=json&method=links.getStats&urls=" . urlencode($url);
$json = json_decode(file_get_contents($rest_url), true);
echo "Facebook Shares = " . @$json[0]['share_count'];
echo "Facebook Likes = " . @$json[0]['like_count'];
echo "Facebook Comments = " . @$json[0]['comment_count'];
}
?>
Leave a Reply