2012-05-01 93 views
0

我從flikr一個RSS feedPHP導航RSS源與命名空間

http://api.flickr.com/services/feeds/photoset.gne?set=72157629920039099&[email protected]&lang=en-us&format=rss_200

在這裏還有一個媒體:說明,媒體:縮略圖等

我想我最難從媒體獲取網址:縮略圖,但我沒有運氣!

我的代碼...

$content = file_get_contents("http://api.flickr.com/services/feeds/photoset.gne?set=72157629920039099&[email protected]&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; 

請可有人點我在正確的方向 - 謝謝!

回答

0

嘗試使用兒童功能:

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

<media:thumbnail url="<?php echo ($thumbA['url']); ?>" />