This topic contains 11 replies, has 2 voices, and was last updated by  van cleef et arpels replique 3 months, 1 week ago.

  • Author
  • #1362 Reply

    Shubham Kumar

    I had received some question from you guys that you are unable to count Facebook share using Facebook Graph API which I had shared in my article . So I’m just giving you another solution of how you can count Facebook share, likes and comments using PHP and FQL query and it doesn’t need any access token.

    Here is the URL which you have to call to count the likes, share and comments of a status or URL:,normalized_url,total_count,share_count,comment_count,like_count,click_count,

    Replace with your Actual URL and it will return a json code looks like:


    Now you can use PHP to count the shares, likes and comments:

    function getData($url){
     $json = json_decode(file_get_contents(",normalized_url,total_count,share_count,comment_count,like_count,click_count,commentsbox_count+FROM+link_stat+WHERE+url+%3D+%27".$url."%27"),true);
     return $json;
    $count = getData("");
    echo "Likes : ".$count['like_count'];
    echo "Shares : ".$count['share_count'];
    echo "Comments : ".$count['comment_count'];

    You can also Use jQuery to count share, likes and comments.

  • #2135 Reply


    Dear shubham how to count a specific post of user in fb

  • #2246 Reply


    Hi shubham.,

    How to get the particular facebook post like, share and comments count?

    • #2385 Reply

      Shubham Kumar

      I will share a complete article on that topic very soon. Have patience.

  • #2372 Reply


    If i integrate this in my app on android, how can i implement the auto fetching of $url for every post i share ? Example : i share a post from my own FB account linked to another app by ACTION_SEND, now i want that app to show these stats without manually entering the URLs.

    I hope i am clear, thanks,

  • #2834 Reply

    Marcial Soto

    In my case, the code retrieves as an array, so the print code will be:

    echo $count[0][‘share_count’];

  • #3472 Reply


    FQL is nos longer supported

  • #3803 Reply

    Jose A Dominguez

    Hi Shubham,
    Is there a way to know if a user is a fan of my facebook page?
    My code is not working…….

    FB.api(‘/me/likes/page id’,function(response){
    if( ){
    if( !isEmpty( ) alert(‘You are a fan!’);
    else alert(‘Not a fan!’); }
    else { alert(‘ERROR!’); }
    }); // function to check for an empty object function isEmpty(obj) { for(var prop in obj) { if(obj.hasOwnProperty(prop)) return false; } return true; }

  • #3883 Reply


    Hallo Leute, ich habe den Code in meiner Seite drin. Seit einer Weile werden die SeitenLIKEs nicht mehr angezeigt 🙁
    Man soll nun einen neuen Code mit nehmen. Kann mir hier jemand helfen?

    function facebook_count($url){

    // Query in FQL
    $fql  = “SELECT like_count”;
    $fql .= ” FROM link_stat WHERE url = ‘$url'”;

    $fqlURL = “” . urlencode($fql);

    // Facebook Response is in JSON
    $response = file_get_contents($fqlURL);
    return json_decode($response);


    $fb = facebook_count(‘’);

    // facebook like count
    echo $fb[0]->like_count;
    Echo ‘test’;

  • #4214 Reply

    van cleef et arpels replique

    Thank you for the sensible critique. Me and my neighbor were just preparing to do a little research on this. We got a grab a book from our area library but I think I learned more from this post. I am very glad to see such wonderful information being shared freely out there.
    van cleef et arpels replique

Reply To: Count Facebook Share, likes and comments with FQL Query
Your information: