0

I'm trying to retrieve feeds from a twitter search to display on various parts of the site. I modified this function to do this yet it works for every feed a try it on except twitter.

function getFeed($feed_url) {

    $content = file_get_contents($feed_url);

    $x = new SimpleXmlElement($content);

    echo "<ul>";

    foreach($x->channel->item as $entry) {
        echo "
        <li>
          <a href='$entry->link' title='$entry->title'>" . $entry->title . "</a>
        </li>";
        }
    echo "</ul>";
}

I am after only the content of the various associative posts. Here is a sample call.

<?php getFeed("feed://search.twitter.com/search.atom?q=berkshire+golf"); ?>

Any ideas,

Marvellous

Samuel
  • 18,286
  • 18
  • 52
  • 88
Walrus
  • 19,801
  • 35
  • 121
  • 199

1 Answers1

0

Twitter's search API is just a simple HTTP request, so your URL should be http:// and not feed:// if you're using file_get_contents

Edit:

You're also using .atom, use rss instead:

http://search.twitter.com/search.rss?q=berkshire+golf

onteria_
  • 68,181
  • 7
  • 71
  • 64
  • Warning: Invalid argument supplied for foreach() in /home/divethe1/public_html/golfbrowser.com/wp-content/themes/master/functions.php on line 539 – Walrus May 14 '11 at 12:29
  • @Robin you should be using the RSS feed, not the atom feed. See inline. – onteria_ May 14 '11 at 12:33