Skip to content

Instantly share code, notes, and snippets.

@mungomash
Created December 1, 2011 02:06
Show Gist options
  • Save mungomash/1412790 to your computer and use it in GitHub Desktop.
Save mungomash/1412790 to your computer and use it in GitHub Desktop.
Use curl to poll the Twitter API directly for a user's follower count.
function getTwitterFollowersCount($screen_name) {
$url = 'http://api.twitter.com/1/users/show.json?screen_name='.$screen_name;
$session = curl_init($url);
curl_setopt($session, CURLOPT_HEADER, false);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($session);
curl_close($session);
$user = json_decode($response);
return $user->followers_count;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment