2014-01-11 108 views
-1

我有一個系統,用於獲取大量視頻從YouTube頻道,就像這樣:如何獲得YouTube視頻中日期的順序上傳

   <?php 
        $feedURL = 'https://gdata.youtube.com/feeds/api/videos?author=UCMlW2qG20hcFYo06rcit4CQ&max-results=48&order=date'; 

        $sxml = simplexml_load_file($feedURL); 

        $i = 0; 
        foreach ($sxml->entry as $entry) { 
         $i++; 

         $media = $entry->children('http://search.yahoo.com/mrss/'); 

         $attrs = $media->group->player->attributes(); 
         $watch = $attrs['url']; 
         $vars; 
         parse_str(parse_url($watch, PHP_URL_QUERY), $vars); 
         $id = $vars['v']; 

         $check = $i % 3; 

         if($check == 1) { 
       ?> 
         <div class="video-col tri-col-1 empty"> 
          <img src="http://img.youtube.com/vi/<?php echo $id ?>/mqdefault.jpg" data-id="<?php echo $id ?>" class="video" /> 
         </div> 
       <?php 
         } else if($check == 2) { 
       ?> 
         <div class="video-col tri-col-2 empty"> 
          <img src="http://img.youtube.com/vi/<?php echo $id ?>/mqdefault.jpg" data-id="<?php echo $id ?>" class="video" /> 
         </div> 
       <?php 
         } else { 
       ?> 
         <div class="video-col tri-col-3 empty"> 
          <img src="http://img.youtube.com/vi/<?php echo $id ?>/mqdefault.jpg" data-id="<?php echo $id ?>" class="video" /> 
         </div> 
       <?php 
         } 

        } 
       ?> 

然而,按時間順序不提供視頻我曾期待將「& order = date」標記添加到URL。如何更改我的代碼以確保視頻按時間順序提供?

回答