Display twitter follower count

Do you want to display your twitter count as text, so it blends in with your new custom theme?
First create a new file – twitter.php and paste in the following code:

<?php
$tw = get_option(“twitterfollowerscount”);
if ($tw['lastcheck'] < ( mktime() – 3600 ) )
{
$xml=file_get_contents(‘http://twitter.com/users/show.xml?screen_name=YOURTWITTERID’);
if (preg_match(‘/followers_count>(.*)</’,$xml,$match)!=0) {
$tw['count'] = $match[1];
}
$tw['lastcheck'] = mktime();
update_option(“twitterfollowerscount”,$tw);
}
echo $tw['count'];
?>

Make sure to replace YOURTWITTERID with your twitter name.

Then simply include the file where you want to display this feature:

<?php include(“twitter.php”); ?>

Montreal Twestival 2009 Cupcakes
Creative Commons License photo credit: clevercupcakes

Leave a comment

You must be logged in to post a comment.