How can I get all video id's from the youtube data feed?
I receive the youtube feed via this (API) URL: http://gdata.youtube.com/feeds/base/users/#userid#/uploads?alt=rss&v=2&orderby=published&client=ytapi-youtube-profile
I already know how to extract the links, descriptions and thumbnails from a Channel, but I want to extract all the video Id's from a Channel (e.g. http://www.youtube.com/watch?v=WWooNnPnHTs)
This is my way. Slow, but it works. :)
function getVideos($channel){
if($channel == ""){
return false;
}
/* Get number of videos */
$books = simplexml_load_file('http://gdata.youtube.com/feeds/base/users/'.$channel.'/uploads?max-results=1&start-index=1');
$numb_videos = $books->children( 'openSearch', true )->totalResults;
settype($numb_videos, "integer");
$ids = array();
$i = 1;
for($i = 1; $i <= $numb_videos; $i++){
$books = simplexml_load_file('http://gdata.youtube.com/feeds/base/users/'.$channel.'/uploads?max-results=1&start-index='.$i);
$ApiLink = $books->entry->id;
settype($ApiLink, "string");
$ApiLink = str_replace("http://gdata.youtube.com/feeds/base/videos/", "", $ApiLink);
array_push($ids, $ApiLink);
}
return $ids;
}