Return to Snippet

Revision: 35885
at November 15, 2010 02:45 by laurentzziu


Initial Code
<?php

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

$prefix = "<h2>My last Tweet</h2>";

$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);
?>

Initial URL


Initial Description


Initial Title
Wordpress Last Twitter Entry

Initial Tags
wordpress, twitter

Initial Language
PHP