/ Published in: PHP

Extracts the most recent tweet from the users RSS feed and auto-detects links.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function parse_feed($feed) { '/<description>(.*?)<\/description>/s', $feed, $tweets, PREG_SET_ORDER ); $tweet = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]","<a href=\"\\0\">\\0</a>", $tweets[1][1]); return $tweet; } $feed = "http://twitter.com/statuses/user_timeline/26248137.rss"; echo parse_feed($twitterFeed); // Without the function and storing it in a user's cookie that is checked every 30min '/<description>(.*?)<\/description>/s', $feed, $tweets, PREG_SET_ORDER ); $tweet = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]","<a href=\"\\0\">\\0</a>", $tweets[1][1]); if (!$_COOKIE['lasttweet']) { echo $tweet; }else{ echo $_COOKIE['lasttweet']; }
Comments
