My goal is to use a playlist ID to get the video ID of each video within that playlist.
I'm having trouble figuring out YouTube's API (I'm a relatively new programmer).
Basically, I want to:
Seems pretty straightforward. I've been grabbing the information from YouTube using simplexml_load_file($url);
in case that is important.
Thanks for the help!
Here you go, I made an example:
<?php
$data = file_get_contents('http://gdata.youtube.com/feeds/api/playlists/PL4BC045240D2FB11B/?v=2&alt=json&feature=plcp');
if (!$data)
throw new Exception("Data retrieval failed.");
$dataAsArray = json_decode($data);
$feed = $dataAsArray->feed->entry;
$videoID_array = array();
if(count($feed))
{
foreach($feed as $item)
array_push($videoID_array, $item->{'media$group'}->{'yt$videoid'}->{'$t'});
}
print_r($videoID_array);
?>
Where PL4BC045240D2FB11B
of course is the Playlist ID! Example PHPFiddle
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments