Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
<?php // Your twitter username. $username = "YOUR.USERNAME"; // Prefix - some text you want displayed before your latest tweet. // (HTML is OK, but be sure to escape quotes with backslashes: for example href=\"link.html\") $prefix = "<h3>Latest Tweet</h3>"; // Suffix - some text you want display after your latest tweet. (Same rules as the prefix.) $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); $tweet = str_replace("&quot;", "\"", $tweet); $tweet = str_replace("&", "&", $tweet); $tweet = str_replace("<a href", "<a href", $tweet); $tweet = str_replace("\">", "\">", $tweet); $tweet = str_replace("</a>", "</a>", $tweet); return $tweet; } $twitterFeed = file_get_contents($feed); echo stripslashes($prefix) . parse_feed($twitterFeed) . stripslashes($suffix); ?>
This paste will be private.
From the Design Piracy series on my blog: