PDA

View Full Version : magpierss - PHP and Reading Atom



freehits
10-26-2006, 04:05 PM
So I use magpierss for sticking rss based info into html pagees, its simple and does the trick, also when coupled with topics_anywhere you can add latest forum topics into any page pretty simple.

I have been trying to grab an atom feed with magpierss and not sure the differences with the Atom feed and how to get the elements.

Not an expert on this junk so maybe someoone can suggest how to get the desired effect.

Magpie insert code is like this


<?php
require_once('magpierss/rss_fetch.inc');
$rss = fetch_rss('http://www.stubhub.com/search/doSearch?pageNumber=1&resultsPerPage=20&format=atom&searchStr=boston+celtics');

echo "".$rss->channel[ 'title']." (.$rss->channel['link'].)";
foreach ($rss->items as $item) {
$href = $item['href'];
$title = $item['title'];
$desc = $item['description'];
echo "

<a href=$href>$title</a>
";
if($desc)
echo $desc;
}
?>



with this it grabs the elements of an rss feed, but when used to try to grab the elements of stubhub's Atom feed


<entry xmlns="">
<title type="text">Atlanta Hawks at Charlotte Bobcats Tickets (Preseason)</title>
<link href="/charlotte-bobcats-tickets/?event_id=335997&amp;search=1"/>
<id>urn:uuid:stubhub-event-id:335997</id>

<updated>2006-08-16T00:00:08Z</updated>
<summary type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">Atlanta Hawks at Charlotte Bobcats Tickets (Preseason)</div>
</summary>
<context type="application/xml">
<result score="0">
<eventId>335997</eventId>

<eventDescription>Atlanta Hawks at Charlotte Bobcats Tickets (Preseason)</eventDescription>
<date>2006-10-27</date>
<time>20:00:00</time>
<dateLastModified>2006-08-16T00:00:08Z</dateLastModified>
<isSparked>0</isSparked>
<genreId>26089</genreId>

<channelId>28</channelId>
<channelName>Sports Tickets</channelName>
<genreDescription>Charlotte Bobcats Tickets</genreDescription>
<genreSegmentationList/>
<genreUrlPath>charlotte-bobcats-tickets</genreUrlPath>
<geoUrlPath>dean-smith-center-event-tickets</geoUrlPath>

<evtSegmentationList/>
<venueId>5404</venueId>
<venueConfigurationId>6412</venueConfigurationId>
<geoId>685</geoId>
</result>
</context>
</entry>
<entry xmlns="">

When grabbing this it gets the top level information
$title = $item['title'];
$desc = $item['description'];

But not sure how to get it to grab the Event level information?

My understanding is that Atom has more levels in its feeds which is why the rss reader is only grabbing the top level information?

Anyone familiar or has a code suggestion to grab the 'result' level elements?