Using PHP To Pull Your Last Tweet Via Twitters Atom Timeline

Ok here is a simple script that will help you pull your latest feed from your twitter atom rss timeline without the use of cURL :)

[cc lang=”php”]

# Enter your twitter username
$username = “websymantecs”;

#page title (if you want one >:P)
$prefix = “<h2>Tweet Tweet</h2>”;

# Suffix – some text you want display after your latest tweet. (Same rules as the page title.)
$suffix = “”;

# Our prepared URL
$feed = “” . $username . “&rpp=1”;

# time to process our request
function parse_feed($feed) {
// time for our data parsing
$phase1 = explode(“<content type=\”html\”>”, $feed);
$phase2 = explode(“</content>”, $phase1[1]);
$tweet = $phase2[0];
$tweet = str_replace(“&lt;”, “<“, $tweet);
$tweet = str_replace(“&gt;”, “>”, $tweet);
$tweet = str_replace(“&quot;”, “”, $tweet);
return $tweet;
# Parsed and echo to the screen.
$twitterFeed = file_get_contents($feed);
echo parse_feed($twitterFeed) . stripslashes($suffix);


Its that simple, enjoy! xD!

After a successful feed, you can use CSS to style the returned data.