Get a twitter count of your shared WordPress content without a plugin
If you run a blog that has an audience who regularly share your pages, why not show them the count of how many times your pages have been shared. Here’s how to get a twitter count of your shared WordPress content without a plugin.
function getTweetCount($url) { $url = urlencode($url); $twitterEndpoint = "http://urls.api.twitter.com/1/urls/count.json?url=%s"; $fileData = file_get_contents(sprintf($twitterEndpoint, $url)); $json = json_decode($fileData, true); unset($fileData); // free memory //print_r($json); return $json['count']; }