I have already posted a tutorial on How to Create a Twitter Feed on Your Web Site and I have been having a lot of emails in regards to people whose hosts do not allow URL file-access. Here is an alternative script that fetches and parses your Twitter RSS feed using a different function. Hopefully it will help out those who can’t use the other script.

The first thing you need to do is get your Twitter RSS feed URL. go to your Profile page and you will see a link in the bottom of your sidebar that says RSS feed. Click on this and then copy the URL. That will be your feed URL.

$feedURL = "http://twitter.com/statuses/user_timeline/68559295.rss"; // change to your feed URL
$doc = new DOMDocument();
$arrFeeds = array();
foreach ($doc->getElementsByTagName('item') as $node) {
    $itemRSS = array ( 
        'title' => $node->getElementsByTagName('title')->item(0)->nodeValue
    array_push($arrFeeds, $itemRSS);
$limit = 5;
for($x=0;$x<$limit;$x++) {
    $title = str_replace('bavotasan: ', '', $arrFeeds[$x]['title']);
    $str = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]","<a href=\"\\0\">\\0</a>", $title); 
    $pattern = '/[#|@][^\s]*/';
    preg_match_all($pattern, $str, $matches);	
    foreach($matches[0] as $keyword) {
        $keyword = str_replace(")","",$keyword);
        $link = str_replace("#","%23",$keyword);
        $link = str_replace("@","",$keyword);
        if(strstr($keyword,"@")) {
            $search = "<a href=\"http://twitter.com/$link\">$keyword</a>";
        } else {
            $link = urlencode($link);
            $search = "<a href=\"http://twitter.com/#search?q=$link\" class=\"grey\">$keyword</a>";
        $str = str_replace($keyword, $search, $str);
    echo '<li>'.$str.'</li>';

Twitter Bird icon provided by Loon Design.