View code | Get code

Basic Youtube API mashup

The example below retrieves data using the YouTube API. Use the code view or zip files above to get started.
Actual YouTube API Request:

title; ?>

entry as $entry) { $title = htmlentities($entry->title); $creator = $entry->author->name; //get unique video id $arr = explode('/',$entry->id); $id = $arr[count($arr)-1]; //get published date $uploaded = $entry->published; //get nodes in media: namespace for media information $media = $entry->children('http://search.yahoo.com/mrss/'); //get video player URL $attrs = $media->group->player->attributes(); $watch = $attrs['url']; //get video description if ($media->group->description && $media->group->description != '') { $description = $media->group->description; } else { $description = 'No description available.'; } //get video thumbnail $attrs = $media->group->thumbnail[0]->attributes(); $thumbnail = $attrs['url']; //get node for video duration $yt = $media->children('http://gdata.youtube.com/schemas/2007'); $attrs = $yt->duration->attributes(); $duration = date("i:s",intval($attrs['seconds'])); //get node for viewer statistics $yt = $entry->children('http://gdata.youtube.com/schemas/2007'); $attrs = $yt->statistics->attributes(); $viewCount = $attrs['viewCount']; //get node for video ratings $gd = $entry->children('http://schemas.google.com/g/2005'); if ($gd->rating) { $attrs = $gd->rating->attributes(); $rating = $attrs['average']; } else { $rating = 0; } ?>