Create a new text file and save it in php format and name it twitter and then paste the following code in the file and save it. So it will be twitter.php
<?php //Your Twitter XML Link $turl="http://twitter.com/users/show.xml?screen_name=YOUR TWITTER USERNAME"; //Initialize the Curl session $ch = curl_init(); //Set curl to return the data instead of printing it to the browser. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //Set the URL curl_setopt($ch, CURLOPT_URL, $turl); //Execute the fetch $data = curl_exec($ch); //Close the connection curl_close($ch); $xml = new SimpleXMLElement($data); $tw = $xml->followers_count; //end get cool feedburner count echo $tw; ?>
After pasting these lines to your file we have to add Twitter user name, so replace the YOUR TWITTER USERNAME with your Twitter user name on the following line
$turl="http://twitter.com/users/show.xml?screen_name=YOUR TWITTER USERNAME";
Then simply add this line of code wherever you want the counter to display:
$turl="http://twitter.com/users/show.xml?screen_name=YOUR TWITTER USERNAME";
Save your twitter.php file to your theme files where you have hosted the blog.
0 comments