Got over 1000 followers on twitter? And you want to flaunt your twitter follower count proudly on your blog. The following PHP code is a PHP cURL code implementation to pull out the twitter followers using REST API. It will get you the number of followers on twitter using the cURL library. Just change the $screen_name and the script is pretty self explanatory. The code is tested working, You are free to do anything with this code, I take no responsibility further however you can ask me for support. I will try to help you out if I can.
NOTE: The code won't work for an hour if you 100 API calls per hours are completed.
<?
// get the number of followers
$screen_name = "atif089";Â Â Â Â Â Â // dont forget to chagne your username
$html = process("http://twitter.com/users/show.xml?screen_name=$screen_name");
// Parse the number of followers
$pattern = '<followers_count>(.*)<\/followers_count>';
ereg($pattern, $html, $matches);
// change this HTML as per your requirement
echo "<a href=\"http://twitter.com/$screen_name\">Follow me on twitter: (".$matches[1]." followers)</a>";
/**
* process : This method open a URL via cURL library
*
* @param string $url (must) This is the URL that you would like to open
* @param string $postargs (optional) Any arguments that you would like to send via POST method
*
*/
function process($url,$postargs=false){
$ch = curl_init($url);
if($postargs !== false){
curl_setopt ($ch, CURLOPT_POST, true);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $postargs);
}
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.11) Gecko/2009060215 Firefox/3.0.11");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
curl_close($ch);
return $response;
}
?>
Related posts:
- How to automatically tweet your blog post
- Pay some bills with Twitter
- 9 things that piss off your twitter followers
- Tweet My Post: Tweet and Twitter your blog posts
- How To Embed a ReTweet Button on Each Blog Post in WordPress

Thanx a lot!its very usefull article.I implemented it.I have one question:
How to show the profile image with the follower number?
Very nice.. Was searching for this !! Thanks you very mch !! will digg !!
you’re welcome Sam