使用 AngularJS
app.controller('oneVideoCtrl', function($scope, $http, $stateParams, $location){
$scope.videos = [];
$scope.youtubeParams = {
key: 'YOUR-API-KEY-HERE',
type: 'video',
kind: 'youtube#video',
maxResults: '1',
part: 'id,snippet',
order: 'viewCount',
channelId: 'YOUR-CHANNEL-ID-HERE',
playlistId: 'YOUR-PLAYLIST-ID-HERE',
}
// Get single specific YouTube video
$http.get('https://www.googleapis.com/youtube/v3/videos?id=VIDEO-ID-HERE', {params:$scope.youtubeParams}).success(function(response){
angular.forEach(response.items, function(child){
console.log (child);
$scope.videos.push(child);
});
});
});