Sample api youtube list

Sample api youtube list
easy using php

super easy use make auto play on youtube api list

<?php
//Get videos from channel by YouTube Data API
$API_key = ‘AIzaSyCyBq9VGAynlBZa8Nxtqw2MvfKDm0KSdKU’;

$channelID = ‘UClwjeR7ja5nR9RuUw1lXs0Q’;

$maxResults = 12;

$videoList = json_decode(file_get_contents(‘https://www.googleapis.com/youtube/v3/search?order=date&part=snippet&channelId=’.$channelID.’&maxResults=’.$maxResults.’&key=’.$API_key.”));

?>
<?php
foreach($videoList->items as $item){
//Embed video
if(isset($item->id->videoId)){
echo ‘<div class=”gallery”>
<iframe width=”300″ height=”200″ src=”https://www.youtube.com/embed/’.$item->id->videoId.’?autoplay=1&loop=1&cc_load_policy=1rel=0&amp;controls=1&amp;showinfo=1″ frameborder=”0″ allowfullscreen></iframe>

</div>’;
}
}
?>

 

 

 

Related posts:

Leave a Reply

Your email address will not be published. Required fields are marked *