Created
December 1, 2011 02:06
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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