June 30th, 2010
I'm a site optimization freak and displaying my latest tweets with the usual code snippet was adding an other javascript to my website, so I searched for an other way of doing it, sans JavaScript. There were probably WordPress plugins for this but I hate having to install too much plugins. The first Google results do the job just fine... for english speakers. If you have special characters or accents, some PHP code won't show them properly.
I have found the solution on NickHeer.com ! Go to this page to get the code to display your latest tweets very simple with PHP or grab it here :
<?php
$username = "your username";
$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 = htmlspecialchars_decode($tweet,ENT_QUOTES);
return $tweet;
}
$twitterFeed = file_get_contents($feed);
echo('"'.parse_feed($twitterFeed).'"');
?>
You just have to edit your username on line 2 before using it !
My name is not Darine Ko. I don't know what kind of job I want to do later, but I love coding, making websites.