Created
June 16, 2017 09:15
-
-
Save webag/93268a1d28167908113e52294d8bc83e to your computer and use it in GitHub Desktop.
youtube api video list php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
$channel_id = "UCrhuhV3v32U8DbI25GUsdIA"; | |
$api_key = "AIzaSyCE-obn38anepy2x4JmF-wOdCseiE234Zo"; | |
$video_list_query = file_get_contents("https://www.googleapis.com/youtube/v3/search?part=snippet&channelId=". $channel_id. "&maxResults=10&order=date&type=video&key=". $api_key); | |
$video_list = json_decode($video_list_query); | |
?> | |
<? | |
foreach ($video_list->items as $video) : | |
$video__thumb = $video->snippet->thumbnails->high->url; | |
$video__title = $video->snippet->title; | |
$video_id = $video->id->videoId; | |
?> | |
<a href="https://www.youtube.com/watch?v=<?=$video_id?>" class="fancy-video btn"> | |
<img src="<?=$video__thumb?>" alt=""><?=$video__title?> | |
</a> | |
<?endforeach; ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment