How to find LinkedIn like counts for a website

| | 1 min read

Most of us have struggled with certain social media buttons to align or fix them in a particular manner. But what if we could get the count figure and display the result in our custom button. Here I wish to share one method to implement this. Let's experiment how to fetch total likes count for a website from LinkedIn.

Pulling likes count of LinkedIn in simple and interesting. The LinkedIn developers have provided one API URL where we could query get our results as response.

Along with the API URL there is one required parameter 'url' we need to pass our site name and one optional parameter 'type' with tells the format of response we needed (eg: XML or JSON).


Performing this programmatically, please refer the below code:

function linked_count($url) {
   $content = file_get_contents("" . $url . "&format=json");
   $content = json_decode($content);
   $retLinked = $content->{'count'};
          return $retLinked;
   } else {
          return 0;
echo "Linked count: " . linked_count('');

The function linked_count will return the total likes for the site url passed.

Please feel free to get in touch with us, if you face any queries while implementations.