/ Published in: PHP
URL: http://www.nealgrosskopf.com/tech/thread.php?pid=57
Display the number of people following you on Twitter using this custom Twitter badge. The code simply returns a number so you can style it however you like.
Expand |
Embed | Plain Text
function curl($url) { $ch = curl_init($url); curl_setopt($ch,CURLOPT_RETURNTRANSFER, true); curl_setopt($ch,CURLOPT_HEADER, 0); curl_setopt($ch,CURLOPT_USERAGENT,"www.YOURDOMAIN.com"); curl_setopt($ch,CURLOPT_TIMEOUT,10); $data = curl_exec($ch); curl_close($ch); return $data; } function GetTwitterFollowerCount($username) { $twitter_followers = curl("http://twitter.com/statuses/user_timeline/".$username.".xml?count=1"); $xml = new SimpleXmlElement($twitter_followers, LIBXML_NOCDATA); return = $xml->status->user->followers_count; }
Comments
Subscribe to comments
You need to login to post a comment.

I have an error on line 17 here. It should read: return $xml->status->user->followers_count;
Sorry for the mistake.