Get the recent tweet from twitter feed using PHP

Recently one of my friend asked me how to display his last tweet in web site. SO in this article I will explain you how to get the most recent tweet to your website by using tweeter feed. This method of getting tweets is working on tweeter feed search method. It will search the recent tweet in tweeter feed for mentioned username and PHP will fetch it to show in your website.

Display the recent tweet from tweeter using tweeter RSS feed

Find the demo below and you can download the example file.

Download FileDemo

Now here is the code for fetch your most recent feed.

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

//Tweeter feed search to get last tweet.
$feed = "" . $username . "&rpp=".$totalTweets."";
function parse_feed($feed) {
$stepOne = explode("", $feed);
$stepTwo = explode("", $stepOne[1]);

$tweet = $stepTwo[0];
$tweet = str_replace("<", "<", $tweet);
$tweet = str_replace(">", ">", $tweet);

return $tweet;
//Get content from feed.
$twitterFeed = file_get_contents($feed);

//Call the function where ever you want
echo parse_feed($twitterFeed);

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>