function parseVideoEntry($video_id) {
$obj= new stdClass;
$url = 'http://gdata.youtube.com/feeds/api/videos/'.$video_id;
$categoriesArray = array();
$xml = simplexml_load_file($url);
$media = $xml->children('http://search.yahoo.com/mrss/');
$obj->title = $media->group->title;
$obj->description = $media->group->description;
$yt = $media->children('http://gdata.youtube.com/schemas/2007');
$attrs = $yt->duration->attributes();
$obj->length = $attrs['seconds'];
$VideoSeconds = $obj->length;
return $VideoSeconds;
}
echo $video = parseVideoEntry("nVhM3IYMF8o");
No comments:
Post a Comment