PHP - No consigo hacer funcionar la API de Dailymotion en un código de API V2 de Youtube

 
Vista:
Imágen de perfil de José Luis

No consigo hacer funcionar la API de Dailymotion en un código de API V2 de Youtube

Publicado por José Luis (1 intervención) el 24/05/2015 23:30:05
Hola a todos, el caso es que mis conocimientos en php son nulos, y estoy intentando hacer funcionar un script reemplazando los datos de Youtube por los de Dailymotion, ya que la api v2 murió y han sacado la v3... pero no consigo hacer que funcione.


CÓDIGO ORIGINAL:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?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 :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?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 la api de youtube por el limit de dailymotion.

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

Lo agradeceria mucho, saludos compañeros.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder