Ver Mensaje Individual
  #1 (permalink)  
Antiguo 24/05/2015, 16:20
Javalinex
 
Fecha de Ingreso: septiembre-2012
Mensajes: 4
Antigüedad: 12 años, 6 meses
Puntos: 0
Reemplazar datos API Dailymotion en código de API V2 Youtue

Hola, pues mis conocimientos en php son nulos, y estoy intentando hacer funcionar un script reemplazando los datos de Youtube por los de Dailymotion, pero no consigo hacer que funcione.


CÓDIGO ORIGINAL:

Código PHP:
<?php
    
      $ytfeedURL 
'https://gdata.youtube.com/feeds/api/videos?q=trailer '.$movie_title.'+official+trailer&max-results=1&v=2';
      
$ytxml simplexml_load_file($ytfeedURL);

    foreach (
$ytxml->entry as $entry) {
        
$media $entry->children('http://search.yahoo.com/mrss/');
        
$attrs $media->group->player->attributes();
        
$watch $attrs['url']; 
        
$attrs $media->group->content->attributes();
        
$player str_replace("https://www.youtube.com/v/"""$attrs['url']); 
    }

    echo
"<iframe width='0' height='0' src='http://www.youtube.com/embed/$player?vq=hd720&amp;autohide=1&amp;autoplay=1&amp;modestbranding=0&amp;showinfo=0&amp;rel=0&amp;iv_load_policy=3' frameborder='0' allowfullscreen></iframe>";    
    
?>

CÓDIGO CON MI FRACASO:

Código PHP:
<?php
    
      $ytfeedURL 
'https://api.dailymotion.com/videos?search=trailer '.$movie_title.'+official+trailer&limit=1';
      
$ytxml simplexml_load_file($ytfeedURL);

    foreach (
$ytxml->entry as $entry) {
        
$media $entry->children('http://search.yahoo.com/mrss/');
        
$attrs $media->group->player->attributes();
        
$watch $attrs['id']; 
        
$attrs $media->group->content->attributes();
        
$player str_replace("http://www.dailymotion.com/video/"""$attrs['id']); 
    }

    echo
"<iframe width='0' height='0' src='http://www.dailymotion.com/embed/video/$player?autoPlay=1' frameborder='0' allowfullscreen></iframe>";    
    
?>

Como se ve simplemente he modificado las URLS, el campo de los datos obtenidos (url por id) y el parametro max-results de youtube por el limit de dailymotion.

¿Alguien puede echarme una mano o decirme donde está el fallo?

Lo agradeceria mucho, saludos compañeros.