How To Add Latest Twits To Your Sidebar

I’ve always wanted to show my last twits in my sidebar. I’ve recently found out how. Here’s a quick tutorial:

Place the following code in your sidebar. Remember to style it properly and replace the username:


<?php
// Your twitter username.
$username = "butterflymedia";
// Prefix - some text you want displayed before your latest tweet.
$prefix = "<h3>My last Tweet</h3>";
// 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("&lt;", "<", $tweet);
    $tweet = str_replace("&gt;", ">", $tweet);
    return $tweet;
}
$twitterFeed = file_get_contents($feed);
echo stripslashes($prefix) . parse_feed($twitterFeed) . stripslashes($suffix);
?>

Tags: , , ,

 
 
 

6 Comments

  1. Payday Loans says:

    thank you for a code I searched him long

  2. nice post, that is a really easy way to do what i want. viva la twitter!

  3. Molnar Laser says:

    Fantastic post! this post have more informative code which more useful for me so thanks for given this.

  4. It sure does help when information gets shared by folks like you. Especially for non-coders like me! I still don’t really use twitter, but am starting to sit up and take notice, because the hype has to have some form of substance behind it, especially when it gets touted as the next Google!

  5. thanks for this post i knew about it already but it will be so helpful for new blogger.

  6. Chip says:

    I’m glad you all find this information helpful. I’ll try to post more tutorials in the future.

Leave a Reply





 
CommentLuv Enabled
 
  • John William: Very informative article! I was wondering that can we submit more arti...
  • CSS Gallery: Great research on these resources! We noticed you didn’t include ht...
  • ramyad: Great! Finally, found a solution. I've been scratching my head on this...
  • san diego seo: There is a new guy on my soccer team who is an Englishman. From time t...
  • Spyke: Thanks for posting this. Many people don't realize that bridge does th...
    follow me on Twitter

    Last searched terms

    Top Browsers

    Top OS

    Site Stats

    Ads

    Ads

    Ajax CommentLuv Enabled 7cc703d7a351bbc1b554fad7c2b1c542 | Tots2Teens | Cariera Piatra Constanta | Verighete