mazman13 Posted February 7, 2007 Share Posted February 7, 2007 I'm trying to find a pretty quick way to incorp XML feeds to your site. I had a HUGE code that I used on my old server, but I now moved to a new GoDaddy server and the code no longer works. So i'm trying to find something that will work. I host podcasts, so XML feeds are pretty important. Thanks guys Quote Link to comment Share on other sites More sharing options...
trq Posted February 7, 2007 Share Posted February 7, 2007 Have you tried google? There should be thousands of hits for this type of thing. Quote Link to comment Share on other sites More sharing options...
mazman13 Posted February 7, 2007 Author Share Posted February 7, 2007 Yeah, and I'm just not having any luck finding anything that will work. The one thing I did find was that one huge PHP code that would read files, but its not working on the new server. Plus there has to be an easier way. I've used sites that can do it for you, i.e.(feedroll.com), but they charge now. And its a pain to go through them when you can (at least try) do it yourself. Thanks guys Quote Link to comment Share on other sites More sharing options...
obsidian Posted February 7, 2007 Share Posted February 7, 2007 For the two RSS feeds on one of my sites, I use a blend of Magpie RSS Parser and custom display. This is one of the lightest weight and easiest to implement I've found. Quote Link to comment Share on other sites More sharing options...
mazman13 Posted February 8, 2007 Author Share Posted February 8, 2007 Hey man- I installed the program on my host, but for some reason its returning "object"...anything i'm doing wrong? <?php require_once('magpierss/rss_fetch.inc'); ?> <strong><font size="3">Download ANY of your favorite past shows here! But hurry, who knows how long they will be available?</font></strong><br /><br /> <?php $url = "http://www.michaelzavala.com/feed.xml"; $rss = fetch_rss($url); echo"$rss"; ?> <br> </p> Quote Link to comment Share on other sites More sharing options...
obsidian Posted February 8, 2007 Share Posted February 8, 2007 Take a look at this example from the Magpie homepage. When you call fetch_rss(), it returns an object that you then need to pull apart to display what you want out of it: <?php require_once 'rss_fetch.inc'; $url = 'http://magpie.sf.net/samples/imc.1-0.rdf'; $rss = fetch_rss($url); echo "Site: ", $rss->channel['title'], "<br> "; foreach ($rss->items as $item ) { $title = $item[title]; $url = $item[link]; echo "<a href=$url>$title</a></li><br> "; } ?> Notice that the variable "$rss->items" holds an array of the feed items, so you can loop through that array and display those items as you see fit on your page. Quote Link to comment Share on other sites More sharing options...
mazman13 Posted February 8, 2007 Author Share Posted February 8, 2007 Thanks man! That worked great... one quick question...running on like no sleep here... If I wanted to get only the 1st 3 on that XML file...how would I limit that? I couldn't do it with a foreach right? Quote Link to comment Share on other sites More sharing options...
obsidian Posted February 8, 2007 Share Posted February 8, 2007 If I wanted to get only the 1st 3 on that XML file...how would I limit that? I couldn't do it with a foreach right? You could, but you'd be better off with a for loop: <?php $limit = 3; for ($i = 0; $i < $limit; $i++) { $line = $rss->items[$i]; // Display $line } ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.