views:

426

answers:

1

I'm trying to set up a php page made up of images from 3 different RSS feeds, in 3 columns. The first feed is from a Wordpress blog, the second from an Etsy store, and the third from a Flickr feed.

What I would like to do is grab the link to the images from the first 3 items in each feed.

Relevant information:

  • The Wordpress feed puts the link in the description, which is formatted as CDATA.
  • The Etsy feed puts the image link as the first item in the description (E.g. &lt;img src=&quot;http://ny-image2.etsy.com/il_155x125.126568958.jpg&amp;quot; /&gt;), but also has it in a <g:image_link> tag.
  • The Flickr feed has the link in the description, but it comes third after links for the user's profile and a link to the photo page. There is also <media:content url="http://farm5.static.flickr.com/4016/4377189674_d6f3aafa81_m.jpg" type="image/jpeg" height="159" width="240"/>.

I've read over the basics of both php and simplexml but it seems what I'd like to do is too complicated for me to figure out on my own. I'd prefer to have a separate functions.php file so I only have to call the function on the web page.

ETA:

I've got the images for the Etsy feed pulled using

<?php
function getEtsyFeed($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'><img src=" . $entry->children('g', true)->image_link . " /></a>
</li>";
}
echo "</ul>";
}
?>

and the images from the Flickr feed pulled using

<?php
function getFlickrFeed($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'><img src=" . $entry->children('media', true)->thumbnail->attributes()->url . " /></a>
</li>";
}
echo "</ul>";
}
?>

I'm still not sure what to do about the blog feed, or how to only show the first 3 images without breaking the code that I do have.

A: 

You should try MagPie.

http://magpierss.sourceforge.net/

JeremySpouken