Posted By

ginoplusio on 10/20/12


count twitter shares countingurl

Versions (?)

Who likes this?

1 person have marked this snippet as a favorite


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

 / Published in: PHP


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("".
  3. "?callback=?&url=".urlencode($url));
  4. preg_match("#(\"count\"):([0-9]*)#",$s,$ar);
  5. return isset($ar[2]) ? $ar[2] : 0;
  6. }
  8. echo readTwitterShares("");

Report this snippet  

You need to login to post a comment.