2012-11-13 37 views
0

我的問題的模糊標題道歉。我只是想弄清楚爲什麼一個朋友的Wordpress網站上的Youtube視頻流突然崩潰。Youtube API視頻流在網站上破碎,需要一些指導

我試圖破譯它現在,但我想我會在這裏發帖,看看有沒有人可以指出我在正確的方向,而我做這個正面或反面。

謝謝。

頁的問題:通過55

Warning: main() [function.main]: Node no longer exists in /home/advocate/public_html/wp-content/themes/process/advocate-tv.php on line 45 

Warning: main() [function.main]: Node no longer exists in /home/advocate/public_html/wp-content/themes/process/advocate-tv.php on line 45 

Fatal error: Call to a member function attributes() on a non-object in /home/advocate/public_html/wp-content/themes/process/advocate-tv.php on line 48 

線40:頁面上http://www.advocatedaily.com/advocatetv/
錯誤

// get video player URL 
        $attrs = $media->group->player->attributes(); 
        $watch = $attrs['url']; 

        // get video thumbnail 
        $attrs = $media->group->thumbnail[0]->attributes(); 
        $thumbnail = $attrs['url']; 

        // get <yt:duration> node for video length 
        $yt = $media->children('http://gdata.youtube.com/schemas/2007'); 
        $attrs = $yt->duration->attributes(); 
        $length = $attrs['seconds']; 

        //get <yt:videoId> node for Video ID 
        $yt = $media->children('http://gdata.youtube.com/schemas/2007'); 
        $playlistVideoID = $yt->videoid; 

問題區域的全片段:

</div> 
    <div id="mainPlaylist" class="grid_6 omega"> 
     <h3 class="title">Legal Feed with Kate Wheeler</h3> 
     <ul id="playlists"> 
      <?php 
       // Loop through each video in each playlist 

       // read feed into SimpleXML object 
       // *Moved into header to load main Video as well 
       $playlistFeedURL = 'http://gdata.youtube.com/feeds/api/playlists/6549D4CA7BB99B16?v=2'; 
       $sxml = simplexml_load_file($playlistFeedURL); 

       // iterate over entries in feed 
       foreach ($sxml->entry as $entry) { 
        // get nodes in media: namespace for media information 
        $media = $entry->children('http://search.yahoo.com/mrss/'); 

        // get video player URL 
        $attrs = $media->group->player->attributes(); 
        $watch = $attrs['url']; 

        // get video thumbnail 
        $attrs = $media->group->thumbnail[0]->attributes(); 
        $thumbnail = $attrs['url']; 

        // get <yt:duration> node for video length 
        $yt = $media->children('http://gdata.youtube.com/schemas/2007'); 
        $attrs = $yt->duration->attributes(); 
        $length = $attrs['seconds']; 

        //get <yt:videoId> node for Video ID 
        $yt = $media->children('http://gdata.youtube.com/schemas/2007'); 
        $playlistVideoID = $yt->videoid; 


        // get <yt:stats> node for viewer statistics 
        $yt = $entry->children('http://gdata.youtube.com/schemas/2007'); 
        $attrs = $yt->statistics->attributes(); 
        $viewCount = $attrs['viewCount']; 

        // get <gd:rating> node for video ratings 
        $gd = $entry->children('http://schemas.google.com/g/2005'); 
        if ($gd->rating) { 
        $attrs = $gd->rating->attributes(); 
        $rating = $attrs['average']; 
        } else { 
        $rating = 0; 
        } 

        ?> 
        <div class="item"> 
         <span class="thumbnail left" rel="<?php echo $entry->id; ?>"> 
         <a href="<?php echo $watch; ?>" rel="<?php echo $playlistVideoID; ?>" onclick="_run();"><img src="<?php echo $thumbnail;?>" /></a> 
         </span> 
         <a href="<?php echo $watch; ?>" rel="<?php echo $playlistVideoID; ?>" onclick="_run();"><?php echo $media->group->title; ?></a> 
         <span class="attr">Duration:</span> <?php printf('%0.2f', $length/60); ?> min. 
         <div class="clear"></div> 
        </div>  
       <?php 
       }   
      ?> 
     </ul> 
    </div> 
    <div class="hr-single grid_16"></div> 
</div> 
<div class="article grid_10"> 
    <div id="recentUploads"> 
     <h3 class="grid_8">Recent Uploads</h3> 
     <div class="clear"></div> 
     <ul> 
      <?php 
      // Loop through each video in each playlist 

      // read feed into SimpleXML object 
      // *Moved into header to load main Video as well 
      $playlistFeedURL = 'http://gdata.youtube.com/feeds/api/playlists/755260781A134FFF?v=2'; 
      $sxml = simplexml_load_file($playlistFeedURL); 

      // iterate over entries in feed 
      foreach ($sxml->entry as $entry) { 
       // get nodes in media: namespace for media information 
       $media = $entry->children('http://search.yahoo.com/mrss/'); 

       // get video player URL 
       $attrs = $media->group->player->attributes(); 
       $watch = $attrs['url']; 

       // get video thumbnail 
       $attrs = $media->group->thumbnail[0]->attributes(); 
       $thumbnail = $attrs['url']; 

       // get <yt:duration> node for video length 
       $yt = $media->children('http://gdata.youtube.com/schemas/2007'); 
       $attrs = $yt->duration->attributes(); 
       $length = $attrs['seconds']; 

       //get <yt:videoId> node for Video ID 
       $yt = $media->children('http://gdata.youtube.com/schemas/2007'); 
       $playlistVideoID = $yt->videoid; 


       // get <yt:stats> node for viewer statistics 
       $yt = $entry->children('http://gdata.youtube.com/schemas/2007'); 
       $attrs = $yt->statistics->attributes(); 
       $viewCount = $attrs['viewCount']; 

       // get <gd:rating> node for video ratings 
       $gd = $entry->children('http://schemas.google.com/g/2005'); 
       if ($gd->rating) { 
       $attrs = $gd->rating->attributes(); 
       $rating = $attrs['average']; 
       } else { 
       $rating = 0; 
       } 

       ?> 
       <div class="item"> 
        <div class="thumbnail left" rel="<?php echo $entry->id; ?>"> 
        <a href="<?php echo $watch; ?>" rel="<?php echo $playlistVideoID; ?>" onclick="_run();"><img src="<?php echo $thumbnail;?>" /></a> 
        </div> 
        <div class=""> 
         <a href="<?php echo $watch; ?>" rel="<?php echo $playlistVideoID; ?>" onclick="_run();"><?php echo $media->group->title; ?></a> 
         <span class="attr">Duration:</span> <?php printf('%0.2f', $length/60); ?> min. 
         <p><?php echo $media->group->description; ?></p> 
        </div> 
        <div class="clear"></div> 
       </div>  
      <?php 
      }   
     ?> 
     </ul> 
    </div> 

回答

3

我認爲發生在我身上的事情可能發生在你身上。

根據您的代碼似乎API不能正確找到播放列表 http://gdata.youtube.com/feeds/api/playlists/6549D4CA7BB99B16?v=2

在試圖解決我自己的困擾呼叫我加入了PL到播放列表ID:* PL * 6549D4CA7BB99B16 http://gdata.youtube.com/feeds/api/playlists/PL6549D4CA7BB99B16?v=2

當用谷歌搜索這個時,我發現一篇博客文章引用了一些關於添加將PL包含到調用中的功能。 apiblog.youtube.com/2012/08/playlists-now-with-more-pl.html

在我的快速搜索中,我沒有注意到任何有關它們的信息,刪除了發送播放列表ID的舊方式。