How to add custom twitter updates in blogs using php
You can easily add custom twitter updates just like we have on our sidebar. I’m not using any plugin and its just a simple php script to show latest update together with my avatar. Alternatively you can also use one of 25 twitter tools for WordPress

Requirements and Steps
Step 1. You need to create and upload a custom image together with your avatar (You can design whatever you want).The dimension used in my sidebar is 80x66px. Example url http://media.honeytechblog.com/s1/images/avatar.gif.
Step 2.Customize the width and style as per your requirements.
Step 3.You need to change the username with your twitter handle. Right now its honeytech.
Step 4. Place the below script in sidebar or you can also place the script into wordpress widgets. You need to have Exec-PHP plugin if you are placing php code in posts, pages and text widgets.
Working Php Code
<h2> Follow @honeytech On Twitter</h2>
<div style="width:340px">
<div style="float:left; font-family:Myriad Pro,arial; font-size:14px;
padding:5px 0px 0px 81px; min-height:60px;
background:url(http://media.honeytechblog.com/s1/images/avatar.gif) no-repeat;">
<?php
// Your twitter username.
$username = "honeytech";
// Prefix - some text you want displayed before your latest tweet.
// (HTML is OK, but be sure to escape quotes with backslashes: for example href="link.html")
$prefix = "";
// Suffix - some text you want display after your latest tweet. (Same rules as the prefix.)
$suffix = "";
$feed = "http://search.twitter.com/search.atom?q=from:" . $username . "&rpp=1";
function parse_feed($feed) {
$stepOne = explode("<content type="html">", $feed);
$stepTwo = explode("</content>", $stepOne[1]);
$tweet = $stepTwo[0];
$tweet = str_replace("'", "'", $tweet);
$tweet = str_replace("<", "<", $tweet);
$tweet = str_replace(">", ">", $tweet);
$tweet = str_replace("&quot;", """, $tweet);
$tweet = str_replace("&lt", "<", $tweet);
$tweet = str_replace("&gt", ">", $tweet);
$tweet = str_replace(""", """, $tweet);
return $tweet;
}
$twitterFeed = file_get_contents($feed);
echo stripslashes($prefix) . parse_feed($twitterFeed) . stripslashes($suffix);
?>
</div>
You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
September 19th, 2010 at 1:43 am
thanks bro
October 21st, 2010 at 12:08 pm
Would something like this work for a Facebook page, as well?
January 26th, 2011 at 3:56 am
Thanks for this. I’ve been having some trouble getting PHP to play nicely with my WordPress installation, and a nice step-by-step process like this really makes it easier.
Thanks again!
Srdjan,
Portable Recorders
April 25th, 2011 at 6:54 pm
Thanks! I’ve been trying to find an easy to integrate Twitter feed code for a really long time now.