Recent Articles

Get Facebook Likes Count of a page using Graph API

Sometimes, being a programmer we may come across a need of a snippet where we have to show the count of likes of a Facebook page. This small code snippet given below uses FaceBook’s graph api and returns the likes count of the page. There is no need to have the FaceBook access token to call the api and get the result.

Remember, this only gives the count and not the persons who liked the page.

That’s it. Next tutorial explains how to get Facebook profile picture with custom dimensions

  • Lakshman

    Very nice, thanks alot

  • krishna

    file_get_contents doesnt work..its showing me error

    • Dnyanesh Pawar

      Hi Krishna,
      Can you try with cURL..

      function get_contents($url)
      $ch = curl_init($url);
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
      curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
      curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
      curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
      $data = curl_exec($ch);
      return $data;

      $json = json_decode(

      Please, do not forget to enable curl extension in apache.

  • cgisoul

    Thank you for your great script. Although when I try this, it works with techrecite ID, but when I replaced it with my fb id, it shows me the following error:

    “error”: {
    “message”: “Unsupported get request.”,
    “type”: “GraphMethodException”,
    “code”: 100

    Appreciated for any help. Thank you.

  • Daniel Paronetto

    Thanks for posting this info. I do have a followup question though… How can I see the likes on a page from one month back?

  • Laurence Gaia

    Here an awesome tools for follow facebook count for several url