Just copy the below code and paste in index.php
Important: Since twitter share count is depreciated you can register at http://opensharecount.com/ by giving just your name ,email and website address and use code like me
<?php
$urlGot = 'http://flipkart.com/'; //Here You can give youe website name
if(isset($_REQUEST['urlGot']) && $_REQUEST['urlGot']!='') {
$urlGot = trim($_REQUEST['urlGot']);
}
?>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
</head>
<!-- Social Button HTML -->
<!-- Twitter -->
<a href="http://twitter.com/share?url=<?php echo $urlGot; ?>" target="_blank" class="share-btn twitter">
<i class="fa fa-twitter"></i>
<span class="NumberTwitterShares"> <?php echo get_tweets($urlGot);?></span>
</a>
<!-- Google Plus -->
<a href="https://plus.google.com/share?url=<?php echo $urlGot; ?>" target="_blank" class="share-btn google-plus">
<i class="fa fa-google-plus"></i>
<span class="NumberGoogleShares"> <?php echo get_plusones($urlGot);?></span>
</a>
<!-- Facebook -->
<a href="http://www.facebook.com/sharer/sharer.php?u=<?php echo $urlGot; ?>" target="_blank" class="share-btn facebook">
<i class="fa fa-facebook"></i>
<span class="NumberFbShares"> <?php echo get_likes($urlGot);?></span>
</a>
<!-- LinkedIn -->
<a href="http://www.linkedin.com/shareArticle?url=<?php echo $urlGot; ?>" target="_blank" class="share-btn linkedin">
<i class="fa fa-linkedin"></i>
<span class="NumberLinkedinShares"> <?php echo get_linkedin($urlGot);?></span>
</a>
<style>
.share-btn {
display: inline-block;
color: #ffffff;
border: none;
padding: 0.5em;
width: 5em;
box-shadow: 0 2px 0 0 rgba(0,0,0,0.2);
outline: none;
text-align: center;
}
.share-btn:hover {
color: #eeeeee;
}
.share-btn:active {
position: relative;
top: 2px;
box-shadow: none;
color: #e2e2e2;
outline: none;
}
.share-btn.twitter { background: #55acee; }
.share-btn.google-plus { background: #dd4b39; }
.share-btn.facebook { background: #3B5998; }
.share-btn.linkedin { background: #4875B4; }
.share-btn.email { background: #444444; }
</style>
<?php
function get_tweets($url) {
$json_string = @file_get_contents('http://opensharecount.com/count.json?url='.$url);
$json = json_decode($json_string, true);
return intval( $json['count'] );
}
function get_likes($url) {
$count = 0;
$json_string = @file_get_contents('http://graph.facebook.com/?ids='.$url);
$json = json_decode($json_string, true);
if(isset($json[$url]['shares']) ){
$count = intval( $json[$url]['shares'] );
}
return $count;
}
function get_plusones($url) {
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "https://clients6.google.com/rpc");
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, '[{"method":"pos.plusones.get","id":"p","params":{"nolog":true,"id":"' . $url . '","source":"widget","userId":"@viewer","groupId":"@self"},"jsonrpc":"2.0","key":"p","apiVersion":"v1"}]');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
$curl_results = curl_exec ($curl);
curl_close ($curl);
$json = json_decode($curl_results, true);
return intval( $json[0]['result']['metadata']['globalCounts']['count'] );
}
function get_linkedin($url) {
$json_string = file_get_contents('https://www.linkedin.com/countserv/count/share?url='.$url);
$breakAllString=explode(":",$json_string);
$cleanCount=explode(",",$breakAllString[1]);
return intval($cleanCount[0]);
}
?>
Important: Since twitter share count is depreciated you can register at http://opensharecount.com/ by giving just your name ,email and website address and use code like me
<?php
$urlGot = 'http://flipkart.com/'; //Here You can give youe website name
if(isset($_REQUEST['urlGot']) && $_REQUEST['urlGot']!='') {
$urlGot = trim($_REQUEST['urlGot']);
}
?>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
</head>
<!-- Social Button HTML -->
<!-- Twitter -->
<a href="http://twitter.com/share?url=<?php echo $urlGot; ?>" target="_blank" class="share-btn twitter">
<i class="fa fa-twitter"></i>
<span class="NumberTwitterShares"> <?php echo get_tweets($urlGot);?></span>
</a>
<!-- Google Plus -->
<a href="https://plus.google.com/share?url=<?php echo $urlGot; ?>" target="_blank" class="share-btn google-plus">
<i class="fa fa-google-plus"></i>
<span class="NumberGoogleShares"> <?php echo get_plusones($urlGot);?></span>
</a>
<!-- Facebook -->
<a href="http://www.facebook.com/sharer/sharer.php?u=<?php echo $urlGot; ?>" target="_blank" class="share-btn facebook">
<i class="fa fa-facebook"></i>
<span class="NumberFbShares"> <?php echo get_likes($urlGot);?></span>
</a>
<!-- LinkedIn -->
<a href="http://www.linkedin.com/shareArticle?url=<?php echo $urlGot; ?>" target="_blank" class="share-btn linkedin">
<i class="fa fa-linkedin"></i>
<span class="NumberLinkedinShares"> <?php echo get_linkedin($urlGot);?></span>
</a>
<style>
.share-btn {
display: inline-block;
color: #ffffff;
border: none;
padding: 0.5em;
width: 5em;
box-shadow: 0 2px 0 0 rgba(0,0,0,0.2);
outline: none;
text-align: center;
}
.share-btn:hover {
color: #eeeeee;
}
.share-btn:active {
position: relative;
top: 2px;
box-shadow: none;
color: #e2e2e2;
outline: none;
}
.share-btn.twitter { background: #55acee; }
.share-btn.google-plus { background: #dd4b39; }
.share-btn.facebook { background: #3B5998; }
.share-btn.linkedin { background: #4875B4; }
.share-btn.email { background: #444444; }
</style>
<?php
function get_tweets($url) {
$json_string = @file_get_contents('http://opensharecount.com/count.json?url='.$url);
$json = json_decode($json_string, true);
return intval( $json['count'] );
}
function get_likes($url) {
$count = 0;
$json_string = @file_get_contents('http://graph.facebook.com/?ids='.$url);
$json = json_decode($json_string, true);
if(isset($json[$url]['shares']) ){
$count = intval( $json[$url]['shares'] );
}
return $count;
}
function get_plusones($url) {
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "https://clients6.google.com/rpc");
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, '[{"method":"pos.plusones.get","id":"p","params":{"nolog":true,"id":"' . $url . '","source":"widget","userId":"@viewer","groupId":"@self"},"jsonrpc":"2.0","key":"p","apiVersion":"v1"}]');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
$curl_results = curl_exec ($curl);
curl_close ($curl);
$json = json_decode($curl_results, true);
return intval( $json[0]['result']['metadata']['globalCounts']['count'] );
}
function get_linkedin($url) {
$json_string = file_get_contents('https://www.linkedin.com/countserv/count/share?url='.$url);
$breakAllString=explode(":",$json_string);
$cleanCount=explode(",",$breakAllString[1]);
return intval($cleanCount[0]);
}
?>