type='video'; $myEmbed->version='1.0'; $myEmbed->provider_name="Youtube"; $myEmbed->provider_url="http://youtube.com"; $myEmbed->resource_url=$url; $xml = new DOMDocument; if(@($xml->load('http://gdata.youtube.com/feeds/api/videos/'.$video_id))) { @$guid = $xml->getElementsByTagName("guid")->item(0)->nodeValue; $link = str_replace("http://www.youtube.com/watch?v=","http://bergengocia.net/indavideobombyoutubemashup/view.php?id=",$guid); $myEmbed->title =$xml->getElementsByTagName("title")->item(0)->nodeValue; $myEmbed->description =$xml->getElementsByTagNameNS("*","description")->item(0)->nodeValue; $myEmbed->author_name =$xml->getElementsByTagName("author")->item(0)->getElementsByTagName("name")->item(0)->nodeValue; $myEmbed->author_url =$xml->getElementsByTagName("author")->item(0)->getElementsByTagName("uri")->item(0)->nodeValue; $myEmbed->thumbnail_url =$xml->getElementsByTagNameNS("*","thumbnail")->item(0)->getAttribute("url"); $myEmbed->thumbnail_width =$xml->getElementsByTagNameNS("*","thumbnail")->item(0)->getAttribute("width"); $myEmbed->thumbnail_height =$xml->getElementsByTagNameNS("*","thumbnail")->item(0)->getAttribute("height"); $med_content_url=$xml->getElementsByTagNameNS("http://search.yahoo.com/mrss/","content")->item(0)->getAttribute("url"); $myEmbed->html= ''."\n". ' '."\n". ' '."\n". ' '."\n". ''; // according to http://code.google.com/apis/youtube/developers_guide_protocol.html#Displaying_information_about_a_video $myEmbed->width="425"; $myEmbed->height="350"; // same as in the html //$myEmbed->duration=$xml->getElementsByTagNameNS($xml->lookupNamespaceURI("*"),"content")->item(0)->getAttribute("duration"); //$time = floor($duration / 60) . ":" . $duration % 60; return $myEmbed; } else throw new Exception404("xxx"); } private function provideXML($url){ $string=""; foreach($this->getEmbed($url) as $key=>$value){ if(isset($value)&& $value!="") $string.=" <".$key.">".$value."\n"; } $string="\n".$string.""; return $string; } private function provideObject($url){ return $this->getEmbed($url); } private function provideJSON($url){ return json_encode($this->getEmbed($url)); } private function provideSerialized($url){ return serialize($this->getEmbed($url)); } public function provide($url,$format="json"){ if($format=="xml"){ return $this->provideXML($url); } else if ($format=="object"){ return $this->provideObject($url); } else if ($format=="serialized"){ return $this->provideSerialized($url); } else { return $this->provideJSON($url);; } } public function __construct($config){ parent::__construct("http://youtube.com",""); } }