PHP
Place the code bellow inside your theme’s function.php file. Don’t forget to change the “TwitterProfileName” with your twitter profile name.
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);
return $tweet;
}
function getTweet(){
$feed = "http://search.twitter.com/search.atom?q=from:TwitterProfileName&rpp=1";
$twitterFeed = file_get_contents($feed);
echo parse_feed($twitterFeed);
}
Now wherever you like to show the twitter status just call the getTweet() function.
jQuery
$.getJSON("http://twitter.com/statuses/user_timeline/username.json?callback=?", function(data) {
$("#theIdOfTheElement").html(data[0].text);
});
Change “#theIdOfTheElement” with the ID of the element you want to show the twitter status in.
A braindump is an easiest way to get into latest knowledge of php and jQuesry. Download the 70-432 dumps and E20-001 dumps to become expert.











You could also fetch the JSON using PHP like this (replacing your username ofc)
<?php $json = file_get_contents("http://twitter.com/statuses/user_timeline/username.json"
;
$json = json_decode($json, true);
echo $json[0]['text'];
// or display last 3
for($i=0; $i < 3 && isset($json[$i]); $i++) {
echo $json[$i]['text'];
}
@Christiaan – Thanks, that’s a good one too
Nice solution. Thanks
@SM –
Nice. THX!
Great solutions, including @Christiaan’s. The PHP one looks similar to an old PHP one I wrote:
http://scriptplayground.com/tutorials/php/Latest-Twitter-Update-With-PHP/
However, these days file_get_contents() may throw an error with your server/the Twitter server. I wrote a PHP Class that uses cURL to bring the feed in to avoid any permissions errors.
http://blog.spookyismy.name/2010/05/18/twitter-integration-class-using-php5-and-curl/
Thank you @Christiaan.
I used CURL for access look here:
http://noranterry.blogspot.com/2011/01/obtener-los-tweets-un-usuario.html
Regards.