Necesito leer el RSS de una cuenta de YouTube e imprimir el enlace del video junto con el titulo y el thumbnail... el tiulo consigo imprimirlo... pero el enlace y el Thumbnail no devido que que se encuentan en un parametro llamado "MEDIA" y no consigo leerlo... si algien sabe como acerlo se lo agradeceria!
Código PHP:
<media:player url="http://www.youtube.com/watch?v=aktvufrvAYE&feature=youtube_gdata" />
<media:thumbnail url="http://i.ytimg.com/vi/aktvufrvAYE/2.jpg" height="90" width="120" time="00:01:03" />
Código PHP:
<entry>
<title>El Hormiguero: Samanta Villar vive '48 días como una diputada'</title>
<link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/UploadsByCuatro/~3/X30MXmDMVY0/watch" />
<dc:subject xmlns:dc="http://purl.org/dc/elements/1.1/">http://gdata.youtube.com/schemas/2007#video</dc:subject>
<dc:subject xmlns:dc="http://purl.org/dc/elements/1.1/">Entertainment</dc:subject>
<dc:subject xmlns:dc="http://purl.org/dc/elements/1.1/">Cuatro</dc:subject>
<dc:subject xmlns:dc="http://purl.org/dc/elements/1.1/">el hormiguero</dc:subject>
<dc:subject xmlns:dc="http://purl.org/dc/elements/1.1/">pablo motos</dc:subject>
<dc:subject xmlns:dc="http://purl.org/dc/elements/1.1/">samanta villar</dc:subject>
<dc:subject xmlns:dc="http://purl.org/dc/elements/1.1/">21 dias</dc:subject>
<dc:subject xmlns:dc="http://purl.org/dc/elements/1.1/">políticos</dc:subject>
<dc:subject xmlns:dc="http://purl.org/dc/elements/1.1/">vacaciones</dc:subject>
<author>
<name>cuatro</name>
<uri>http://gdata.youtube.com/feeds/api/users/cuatro</uri>
</author>
<issued>2010-02-11T11:08:30-08:00</issued>
<modified>2010-02-11T11:08:30-08:00</modified>
<id>http://gdata.youtube.com/feeds/api/videos/aktvufrvAYE</id>
<content>http://www.cuatro.com/el-hormiguero
El programa El Hormiguero hace una parodia de las vacaciones de los diputados con Samanta Villar en '48 días de diputada'</content>
<gd:comments xmlns:gd="http://schemas.google.com/g/2005">
<gd:feedLink href="http://gdata.youtube.com/feeds/api/videos/aktvufrvAYE/comments" countHint="1" />
</gd:comments>
<media:group xmlns:media="http://search.yahoo.com/mrss/">
<media:category label="Entertainment" scheme="http://gdata.youtube.com/schemas/2007/categories.cat">Entertainment</media:category>
<media:content xmlns:yt="http://gdata.youtube.com/schemas/2007" url="http://www.youtube.com/v/aktvufrvAYE?f=user_uploads&app=youtube_gdata" type="application/x-shockwave-flash" medium="video" isDefault="true" expression="full" duration="126" yt:format="5" />
<media:content xmlns:yt="http://gdata.youtube.com/schemas/2007" url="rtsp://v3.cache5.c.youtube.com/CigLENy73wIaHwmBAe_6uW9LahMYDSANFEgGUgx1c2VyX3VwbG9hZHMM/0/0/0/video.3gp" type="video/3gpp" medium="video" expression="full" duration="126" yt:format="1" />
<media:content xmlns:yt="http://gdata.youtube.com/schemas/2007" url="rtsp://v6.cache2.c.youtube.com/CigLENy73wIaHwmBAe_6uW9LahMYESARFEgGUgx1c2VyX3VwbG9hZHMM/0/0/0/video.3gp" type="video/3gpp" medium="video" expression="full" duration="126" yt:format="6" />
<media:description type="plain">http://www.cuatro.com/el-hormiguero
El programa El Hormiguero hace una parodia de las vacaciones de los diputados con Samanta Villar en '48 días de diputada'</media:description>
<media:keywords>Cuatro, el hormiguero, pablo motos, samanta villar, 21 dias, políticos, vacaciones</media:keywords>
<media:player url="http://www.youtube.com/watch?v=aktvufrvAYE&feature=youtube_gdata" />
<media:thumbnail url="http://i.ytimg.com/vi/aktvufrvAYE/2.jpg" height="90" width="120" time="00:01:03" />
<media:thumbnail url="http://i.ytimg.com/vi/aktvufrvAYE/1.jpg" height="90" width="120" time="00:00:31.500" />
<media:thumbnail url="http://i.ytimg.com/vi/aktvufrvAYE/3.jpg" height="90" width="120" time="00:01:34.500" />
<media:thumbnail url="http://i.ytimg.com/vi/aktvufrvAYE/0.jpg" height="240" width="320" time="00:01:03" />
<media:title type="plain">El Hormiguero: Samanta Villar vive '48 días como una diputada'</media:title>
<yt:duration xmlns:yt="http://gdata.youtube.com/schemas/2007" seconds="126" />
</media:group>
<gd:rating xmlns:gd="http://schemas.google.com/g/2005" average="4.6666665" max="5" min="1" numRaters="12" rel="http://schemas.google.com/g/2005#overall" />
<yt:statistics xmlns:yt="http://gdata.youtube.com/schemas/2007" favoriteCount="3" viewCount="222" />
<feedburner:origLink>http://www.youtube.com/watch?v=aktvufrvAYE&feature=youtube_gdata</feedburner:origLink>
</entry>
E aqui mi codigo PHP Lector RSS simple...
Código PHP:
<?php
/*
Created by Global Syndication's RSS Parser
[noparse][url]http://www.globalsyndication.com/rss-parser[/url][/noparse]
*/
set_time_limit(0);
$file = "http://gdata.youtube.com/feeds/api/users/cuatro/uploads";
$rss_channel = array();
$currently_writing = "";
$main = "";
$item_counter = 0;
function startElement($parser, $name, $attrs)
{ global $rss_channel, $currently_writing, $main;
switch($name)
{ case "RSS":
case "RDF:RDF":
case "ITEMS":
$currently_writing = ""; break;
case "CHANNEL": $main = "CHANNEL"; break;
case "PLAYER":
$main = "PLAYER";
$rss_channel["PLAYER"] = array();
break;
case "ENTRY": $main = "ENTRYS"; break;
default: $currently_writing = $name; break;
}
}
function endElement($parser, $name)
{ global $rss_channel, $currently_writing, $item_counter;
$currently_writing = "";
if($name == "ENTRY")
{ $item_counter++;}
}
function characterData($parser, $data)
{ global $rss_channel, $currently_writing, $main, $item_counter;
if($currently_writing != "")
{ switch($main)
{ case "CHANNEL":
if(isset($rss_channel[$currently_writing]))
{ $rss_channel[$currently_writing] .= $data;}
else
{ $rss_channel[$currently_writing] = $data;}
break;
case "PLAYER":
if(isset($rss_channel[$main][$currently_writing]))
{ $rss_channel[$main][$currently_writing] .= $data;}
else
{ $rss_channel[$main][$currently_writing] = $data;}
break;
case "ENTRYS":
if(isset($rss_channel[$main][$item_counter][$currently_writing]))
{ $rss_channel[$main][$item_counter][$currently_writing] .= $data;}
else
{ $rss_channel[$main][$item_counter][$currently_writing] = $data;}
break;
}
}
}
$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");
if (!($fp = fopen($file, "r")))
{ die("could not open XML input");}
while($data = fread($fp, 4096))
{ if(!xml_parse($xml_parser, $data, feof($fp)))
{ die(sprintf("XML error: %s at line %d",xml_error_string(xml_get_error_code($xml_parser)),xml_get_current_line_number($xml_parser)));
}
}
xml_parser_free($xml_parser);
// output HTML
if(isset($rss_channel["ENTRYS"]))
{ if(count($rss_channel["ENTRYS"]) > 0)
{ for($i = 0;$i < count($rss_channel["ENTRYS"]);$i++)
{ if (isset($rss_channel["ENTRYS"][$i]["LINK"]))
{print ("\n<div class=\"itemtitle\"><a href=\"" . $rss_channel["ENTRYS"][$i]["PLAYER"] . "\" target=\"_blanck\">" . utf8_decode($rss_channel["ENTRYS"][$i]["PLAYER"]) . "</a></div>");}
else
{print ("\n<div class=\"itemtitle\">" . utf8_decode($rss_channel["ENTRYS"][$i]["TITLE"]) . "</div>");}
}
}else
{ print ("<b>There are no articles in this feed.</b>");}
}
?>