Jump to content

Receiving parsed RSS feed data into PHP (Problem)


grantp22

Recommended Posts

Hi, Can anybody please explain to me what is wrong with my code below, I have been trying to retrieve an images URL from an RSS feed to display on my website but the code I have written does not get the image url or length. But I am able to retrieve feed titles, descriptions, etc...

 

But this source will just not work, I have tried so many variations of this code and still nothing, what am I doing wrong. BTW I am using the free opensource Magpie rss reader, which works freat by the way, with the exception of the <enclosure> element which I just cannot get to work. Any help will be greatly appreciated!

 

Here is what I am doing:

 

<?php
  include_once('magpie/magpierss/rss_fetch.inc');
  define('MAGPIE_CACHE_DIR', '/cache');
  define('MAGPIE_CACHE_AGE', 900);

  $feed = 'http://feeds.iol.co.za/iol_new/thumbtribe/picture_iol_frontpage.rss';
  $rss = fetch_rss($feed);

  $items = $rss->items;

  $title = $item['title'];
  $url = $item['link'];
  $description= $item['description'];
  $picuri = $item['enclosure'][0]['url'];
  $enclosure = $item['enclosure'][0]['length'];


  echo "<enclosure url='".$picuri."' length='".$enclosure."' type='MIME' title='big'>\n";
  echo "<div class=\"right1\" style=\"width: 100%; text-align:left; padding-top:5px; padding-left:37px; padding-right:37px\"><font color=\"#000000\" style=\"font-size: 11px; text-align: justify;\">".$description."</font>\n";
?>

 

All I need is to display one little picture, surely it can't be that involved or am I just missing the point completely?

 

Thanks in advance

Grant

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.