Here's the ouput :
See that text after the Tweet button? It's so annoying that it is supposed to be there but... yah it's there. xD
A scren capture from the Google Chrome
debugger.
It's happening somewhere here.
echo sprintf('<a id="share" target="_blank" data-count="%d" title="Share on Twitter" href="http://twitter.com/share?text=%s&url=%s" class="btn btn-counter" rel="nofollow">%s</a>', $tweets, $text, $url, $placeholder);
Here's the complete PHP
code:
<?php
function get_tweets($url){
$api = "http://urls.api.twitter.com/1/urls/count.json?url=";
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_URL, $api.$url);
$result = json_decode(curl_exec($ch));
return $result->count;
}
function tweet($url, $text = '', $placeholder = 'Tweet'){
$text = urlencode($text);
$url = urlencode($url);
$tweets = get_tweets($url);
echo sprintf('<a id="share" target="_blank" data-count="%d" title="Share on Twitter" href="http://twitter.com/share?text=%s&url=%s" class="btn btn-counter" rel="nofollow">%s</a>', $tweets, $text, $url, $placeholder);
}
tweet('https://www.youtube.com/watch?v=[url]', 'The most beautiful story.');
?>
HERE'S THE SUPER COMPLETE CODE :
<!DOCTYPE html>
<html>
<head>
<title></title>
<style type="text/css">
#share{
text-decoration: none;
color: #fff;
width: 200px;
height: 50px;
background-color: #7fad33;
border-radius: 3px;
padding: 10px;
}
</style>
<script type="text/javascript">
function popupwindow(url, title, w, h) {
var sheight = window.innerHeight || document.body.clientHeight;
var swidth = window.innerWidth || document.body.clientWidth;
var left = (swidth/2)-(w/2);
var top = (sheight/2)-(h/2);
return window.open(url, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
}
</script>
</head>
<body>
<center>
<a id="share" class="facebook" target="_blank" onclick="return !popupwindow(this.href, 'Facebook', '640', '300')" href="http://www.facebook.com/sharer/sharer.php?u=https://www.youtube.com/watch?v=ZO1klxIbUfA">Share</a>
<?php
function get_tweets($url){
$api = "http://urls.api.twitter.com/1/urls/count.json?url=";
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_URL, $api.$url);
$result = json_decode(curl_exec($ch));
return $result->count;
}
function tweet($url, $text = '', $placeholder = 'Tweet'){
$text = urlencode($text);
$url = urlencode($url);
$tweets = get_tweets($url);
echo sprintf('<a id="share" target="_blank" data-count="%d" title="Share on Twitter" href="http://twitter.com/share?text=%s&url=%s" class="btn btn-counter" rel="nofollow">%s</a>', $tweets, $text, $url, $placeholder);
}
tweet('https://www.youtube.com/watch?v=[url]', 'The most beautiful story.');
?>
</center>