Wednesday, October 13, 2010

TutZone- Tutorials, Design news and Inspiration

TutZone- Tutorials, Design news and Inspiration

Link to TutZone

How To Display Twitter Counter in Text

Posted: 13 Oct 2010 08:42 AM PDT


If you have followed the last tutorial How To Display Feedburner Subscriber Count As Text Instead Of Chicklet I’m sure you would like to know how to do same with Twitter so that your follower count is displayed as a text, rather than using some badge. Just follow this simple tutorial.

Procedure:

Note: Do take backup of your theme before you try this.

01. Just Add below code where you want to display all your twitter counter as text:

<?php
$twit = file_get_contents('http://twitter.com/users/show/TUTZONE.xml');
$begin = '<followers_count>'; $end = '</followers_count>';
$page = $twit;
$parts = explode($begin,$page);
$page = $parts[1];
$parts = explode($end,$page);
$tcount = $parts[0];
if($tcount == '') { $tcount = '0'; }
echo '<div class="twitter-badge"><strong>'.$tcount.' </strong> Followers</div>';

?>

Just Change TUTZONE to your twitter username and you should be good.

This concludes this simple and useful tutorial. Hope you like it.

Source

No comments:

Post a Comment