Ver Mensaje Individual
  #3 (permalink)  
Antiguo 15/03/2012, 07:24
charlescuellar
 
Fecha de Ingreso: abril-2008
Mensajes: 310
Antigüedad: 16 años
Puntos: 4
Respuesta: api youtube como se pagina

amigo mira el codigo q uso

Código PHP:
Ver original
  1. <ul id="grid-content">
  2. <?php
  3.    $feedURL = "http://gdata.youtube.com/feeds/api/playlists/5735D8B716DFF2CF?v=2";
  4.     // read feed into SimpleXML object
  5.     $sxml = simplexml_load_file($feedURL);
  6.     ?>
  7.       <h1><?php echo $sxml->title; ?></h1>
  8.     <?php
  9.     // iterate over entries in feed
  10.     foreach ($sxml->entry as $entry) :
  11.       // get nodes in media: namespace for media information
  12.       $media = $entry->children('http://search.yahoo.com/mrss/');
  13.      
  14.       // get video player URL
  15.       $attrs = $media->group->player->attributes();
  16.       $watch = $attrs['url'];
  17.      
  18.       // get video thumbnail
  19.       $attrs = $media->group->thumbnail[0]->attributes();
  20.       $thumbnail = $attrs['url'];
  21.            
  22.       // get <yt:duration> node for video length
  23.       $yt = $media->children('http://gdata.youtube.com/schemas/2007');
  24.       $attrs = $yt->duration->attributes();
  25.       $length = $attrs['seconds'];
  26.      
  27.       // get <yt:stats> node for viewer statistics
  28.       $yt = $entry->children('http://gdata.youtube.com/schemas/2007');
  29.       $attrs = $yt->statistics->attributes();
  30.       $viewCount = $attrs['viewCount'];
  31.      
  32.       // get <gd:rating> node for video ratings
  33.       $gd = $entry->children('http://schemas.google.com/g/2005');
  34.       if ($gd->rating) {
  35.         $attrs = $gd->rating->attributes();
  36.         $rating = $attrs['average'];
  37.       } else {
  38.         $rating = 0;
  39.       }
  40.       ?>
  41.      
  42.       <li>
  43.     <div class="view view-first">        
  44.  
  45.      <a href="<?php echo $watch; ?>"><img src="<?php echo $thumbnail;?>" /></a>
  46.  
  47.      <div class="mask">
  48.      <h2 style="padding: 5px;"><?php echo Html::link("video/{$item->id}", substr($media->group->title,0,20)) ?></h2>
  49.      <?php echo Html::link("video/{$item->id}","Play","class='button .btn-danger'"); ?>
  50.      </div>        
  51.     </div>
  52.     </li>  
  53.  
  54.     <?php  endforeach; ?>
  55.  
  56. </ul>