Return to Snippet

Revision: 60093
at October 20, 2012 07:45 by ginoplusio


Initial Code
function readTwitterShares($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 readTwitterShares("http://www.dailybest.it");

Initial URL
http://www.barattalo.it/2012/10/19/how-many-times-a-web-link-has-been-shared-on-twitter/

Initial Description
Here is a function that read the number of times a url is shared on twitter.

Initial Title
Counting how many times a web link has been shared on Twitter

Initial Tags
twitter

Initial Language
PHP