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
And here’s the download link (you have to pay with a tweet to download it)
[php]
echo “<iframe src=’//www.paywithatweet.com/dlbutton02.php?id=505354a3-5be5-4231-b6d0-0076f78cb7a5′ class=’spaced-right’ name=’paytweet_button’ scrolling=’no’ frameborder=’no’ height=’24px’ width=’240px’></iframe>”;
[/php]