display the number of times a url is shared on twitter

This will display the number of times a url is shared on twitter

 

function TwitterShares($url)
{
$s = file_get_contents(“http://urls.api.twitter.com/1/urls/count.json”.”?callback=?&url=”.urlencode($url));
preg_match(“#(\”count\”):([0-9]*)#”,$s,$ar);
return isset($ar[2]) ? $ar[2] : 0;
}

echo TwitterShares(“http://www.google.com”);

SHARE
Previous articleHTTP Redirection
Next articleLogging function

LEAVE A REPLY

Please enter your comment!
Please enter your name here

*