1 2 3 4 5 6 |
//Must enable google API + Youtube v3 API // https://developers.google.com/youtube/v3/docs/search/list Using this "q" for searching video account channelID. After that put channelID into channelID field. then get all video from the specifies youtube account. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
<?php $API_Key = 'KEY'; $Channel_ID = "Channel_ID"; $Max_Results = 10; $apiData = @file_get_contents('https://www.googleapis.com/youtube/v3/search?order=date&part=snippet&channelId='.$Channel_ID.'&maxResults='.$Max_Results.'&key='.$API_Key.''); if($apiData){ $videoList = json_decode($apiData); }else{ echo 'Invalid API key or channel ID.'; } if(!empty($videoList->items)){ foreach($videoList->items as $item){ // Embed video if(isset($item->id->videoId)){ echo ' <div class="yvideo-box"> <iframe width="280" height="150" src="https://www.youtube.com/embed/'.$item->id->videoId.'" frameborder="0" allowfullscreen></iframe> <h4>'. $item->snippet->title .'</h4> <h5>'. $item->id->videoId .'</h5> </div>'; } } }else{ echo '<p class="error">'.$apiError.'</p>'; } |
Done