Ver Mensaje Individual
  #3 (permalink)  
Antiguo 20/10/2008, 14:12
Avatar de pato12
pato12
 
Fecha de Ingreso: septiembre-2007
Ubicación: Salta
Mensajes: 1.620
Antigüedad: 16 años, 7 meses
Puntos: 101
Buscar en YouTube.com con el API

Hola,
Me arme un codigo que usa el API de YouTube.com para buscar videos:
Código PHP:
require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Gdata_YouTube');
function 
Buscar_Youtube($searchTerms,$max 25$index 1)
{
  
$yt = new Zend_Gdata_YouTube(); 
  
$query $yt->newVideoQuery();
  
$query->setRacy('exclude');
  
$query->setOrderBy('viewCount');
  
$query->setMaxResults($max);
  
$query->setStartIndex($index);
  
$query->setFormat(5);
  
$query->setVideoQuery($searchTerms);
  
$videoFeed $yt->getVideoFeed($query);
  return 
$videoFeed;
}
function 
echoVideoMusica($videoFeed$displayTitle null){
  
$dat=array();
  if (
$displayTitle === null)$displayTitle $videoFeed->title->text;
  foreach (
$videoFeed as $videoEntry) {
$dat[]='<object width="425" height="344"><param name="movie" value="'.$videoEntry->getFlashPlayerUrl().'"></param><param name="allowFullScreen" value="true"></param><embed wmode="transparent" src="'.$videoEntry->getFlashPlayerUrl().'" type="application/x-shockwave-flash" allowfullscreen="true" width="425" height="344"></embed></object>';
  }
return 
implode('',$dat);
}
function 
BuscarYouTube($t,$i 1,$f 1){
return 
echoVideoMusica(Buscar_Youtube($t,$i,$f));

Y por ejemplo lo ejecuto:
Código PHP:
$video=BuscarYouTube($dat['titulo'].$a,1,1);echo $video
Anda bien, pero no se como buscar por categoria.
Gracias
Salu2
__________________
Half Music - www.halfmusic.com

Última edición por pato12; 20/10/2008 a las 14:18