Posted By

ginoplusio on 10/20/12


Tagged

count twitter shares countingurl


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

Priestd09


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


 / Published in: PHP
 

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

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

  1. function readTwitterShares($url) {
  2. $s = file_get_contents("http://urls.api.twitter.com/1/urls/count.json".
  3. "?callback=?&url=".urlencode($url));
  4. preg_match("#(\"count\"):([0-9]*)#",$s,$ar);
  5. return isset($ar[2]) ? $ar[2] : 0;
  6. }
  7.  
  8. echo readTwitterShares("http://www.dailybest.it");

Report this snippet  

You need to login to post a comment.