Bladephp: Now with 8+ codeigniter, php, and laravel project 8+ php project From $37/Month From Rs. 2499/Month

How to get facebook like, share and comment count using PHP

by
Category:php
php html
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 Login with Facebook in CodeIgniter and 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'];
}
?>

0 Comments


Html code work in comment box


Related Post