Count Social Media Shares PHP

tl;dr Social networks helps business grow, with that being said, it’s always nice to know how

Social networks helps business grow, with that being said, it’s always nice to know how many times your articles were shared. It also encourage your readers to share your content more. every blog (if not every website) should have a sharing widget, but searching for the right widget, personally, took me a lot more than writing my own. Every plugin / script I found was missing something, so I decided to write my own.

A Count Social Media Shares written in PHP. What the script does is it counts all shares from 8 social media networks so far ( Twitter, Buffer, Facebook, LinkedIn, Google Plus, StumbleUpon, Delicious and Pinterest)

The script is really useful and give you instant insight of your share counts on social media

Initializing the script is even simpler

require_once("shareCount.php");
$shareCount = new shareCount("http://YourDomian.com");

And displaying the results is really easy too

$datas = $shareCount->getCount();
echo "Total Shares is " . $datas['count'];
echo "Facebook Shares is: ".$datas['facebook'];

The script uses file_get_content, if it fails it switches to fopen if it fails it switches to cURL


This means cURL should be installed on your website.

I’ve also added a quick function to convert thousands to K and millions to M and so on for Billions and Trillions

I’ve written a quick files with some CSS and bootstrap to make teh widget look good when you’re viewing it. The main purpose of the script is to give you the data, not the looks and feel. So feel free to design it as you wish

Here’s a screenshot of how it basically looks with some basic CSS styling

Social Media Count PHP
Social Media Count PHP

And here’s the download link (you have to pay with a tweet to download it)


Also published on Medium.


About The Author

Brand Strategy - MENA I help brands excel on Twitter Speaker ( Twitter for business - Periscope for Business)



Join +4200 Subscribers

Subscribe and we will send you password to our execlusive content.

You can unsubscribe at any time.

@


Leave a reply

Your email address will not be published.