Created
June 16, 2017 08:48
-
-
Save webag/e86cdc3c2bca4a19699e92fcbf40f1e9 to your computer and use it in GitHub Desktop.
youtube api video list
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
/*********************** | |
YouTube api feed BEGIN | |
***********************/ | |
$(document).ready(function () { | |
var channelId = "UCrhuhV3v32U8DbI25GUsdIA"; | |
var apiKey = "AIzaSyCE-obn38anepy2x4JmF-wOdCseiE234Zo"; | |
$.ajax({ | |
type: "GET", | |
url: "https://www.googleapis.com/youtube/v3/search?part=snippet&channelId=" + channelId + "&maxResults=10&order=date&type=video&key=" + apiKey, | |
success: (function (data) { | |
$.each(data.items, function (i, item) { | |
var video = {}; | |
video.id = item.id.videoId; | |
$.ajax({ | |
type: "GET", | |
url: "https://www.googleapis.com/youtube/v3/videos?id=" + item.id.videoId + "&key=" + apiKey + "&part=snippet", | |
success: function (data) { | |
var item_info = data.items[0].snippet; | |
video.title = item_info.title; | |
video.thumb = item_info.thumbnails.standard.url; | |
$('#vid').append( | |
'<div>' + | |
'<a href="https://www.youtube.com/watch?v='+video.id+'" class="fancy-video btn">'+video.title+'</a>' + | |
'<img src="'+video.thumb+'" alt="">' + | |
'</div>' | |
); | |
init_fancy__video(); | |
} | |
}); | |
}); | |
}) | |
}); | |
}); | |
/*********************** | |
YouTube api feed END | |
***********************/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment