Using Magpie for an RSS Feed

We currently are using Magpie for most of our other RSS feeds that we have on our sites, but for some reason I don't know how to display just the image...

I want to display the title of the file and the image. Heres what I have so far.

<?PHP
define('MAGPIE_CACHE_DIR', './magpie_cache');
define('MAGPIE_CACHE_ON', 1);
define('MAGPIE_CACHE_AGE', 600);
require_once 'rss_fetch.inc';

$url = 'http://calyou.cup.edu/test/zenphoto/rss.php';
$rss = fetch_rss($url);

foreach ($rss->items as $item ) {
$title = $item[title];
$image = $item[what goes here?];
echo "$title<br>\n";
echo "<img width='300' heigth='400' src=$image><br>\n";
}
?>

Any help on how I could get the image to display? That file is located at
http://calyou.cup.edu/photo_rss

Comments

  • acrylian Administrator, Developer
    I don't know or ever used Magpie. Is that to display the feed on a page directly? Well, in that case it seems to work in Safari 3.1, I see the player name and below the photo, but Firefox gives this error you probably know:
    Parse error: syntax error, unexpected T_VARIABLE, expecting ',' or ';' in /Volumes/Zeus2/WebServer/photo_rss/index.php on line 14
  • koury Member
    I got it to work now. However with :

    <?PHP
    define('MAGPIE_CACHE_DIR', './magpie_cache');
    define('MAGPIE_CACHE_ON', 1);
    define('MAGPIE_CACHE_AGE', 600);
    require_once 'rss_fetch.inc';

    $url = 'http://calyou.cup.edu/test/zenphoto/rss.php';
    $rss = fetch_rss($url);
    $items = array_slice($rss->items, 0, 3);
    foreach ($items as $item ) {
    $title = $item['title'];
    $image = $item['description'];
    $href = $item['link'];
    echo "$title<br>\n";
    echo "$image<br><br><br><br><br>\n";
    }
    ?>

    But when I click the links (so it will take me to the zenphoto page) it breaks after and space thats in the file name.
    For example if I click "Brian Mohr" it takes me to http://calyou.cup.edu/test/zenphoto/index.php?album=Team_and_Head_shots/Players&image=Brian
    instead of http://calyou.cup.edu/test/zenphoto/index.php?album=Team_and_Head_shots/Players&#38;image=Brian Mohr.JPG

    It does the same thing with " + "s as well.

    Any tips will be appreciated.
  • try something like

    `$href = urlencode($item['link']);`

    and make sure the a tag attributes are in quotes, e.g. href=... is href="..."
Sign In or Register to comment.