A simple way to display your tweets with php

Have you checked my right sidebar having latest tweets? It is very simple to display them in wordpress/any page using simple php code and styling.

Here is the code that i used

<div style="width:300px">
<div style="float:left; font-family:Myriad Pro,arial; font-size:14px; padding:5px 0px 0px 81px; min-height:60px; background:url(https://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("&apos;", "’", $tweet);
$tweet = str_replace("&lt;", "<", $tweet);
$tweet = str_replace("&gt;", ">", $tweet);
$tweet = str_replace("&amp;quot;", "&quot;", $tweet);
$tweet = str_replace("&amp;lt", "<", $tweet);
$tweet = str_replace("&amp;gt", ">", $tweet);
$tweet = str_replace("&quot;", """, $tweet);


return $tweet;

}

$twitterFeed = file_get_contents($feed);

echo stripslashes($prefix) . parse_feed($twitterFeed) . stripslashes($suffix);

?>


</div>
</div>

How to customize

1. Change the username

// Your twitter username.
$username = "honeytech";

2. Change the display image
background:url (http://media.honeytechblog.com/s1/images/avatar.gif)

Having any problem

Ping me @honeytech