0

I have an RSS feed from flikr

http://api.flickr.com/services/feeds/photoset.gne?set=72157629920039099&nsid=50910794@N07&lang=en-us&format=rss_200

In here there is a media:description, media:thumbnail e.t.c

I am trying my hardest to get the URL from the media:thumbnail but I am having no luck whatso ever!

My code...

$content = file_get_contents("http://api.flickr.com/services/feeds/photoset.gne?set=72157629920039099&nsid=50910794@N07&lang=en-us&format=rss_200");

$x = new SimpleXmlElement($content);

$ourItems = "";

foreach($x->channel->item as $entry) {

    $thumbParent   = $entry->children("media");
    $thumb         = $thumbParent->thumbnail->attributes();
    $thumbW        = $thumb['width']; 
    $thumbH        = $thumb['height']; 
    $thumbURL      = $thumb['url']; 

   $ourItems .= "<li>\n"
                    ."<a href='$entry->link' title='$entry->title'>\n"
                       ."<img src='" . $thumbURL . "' />\n"
                    ."</a>\n"
                 ."</li>\n";

}

return $ourItems;

Please can someone point me in the correct direction - thanks!

4

1 回答 1

0

尝试使用 children 函数:

 $thumbA = $item->children('media', true)->thumbnail->attributes();

 <media:thumbnail url="<?php echo ($thumbA['url']); ?>" />
于 2013-04-16T12:53:27.307 回答