0
我已經得到了這段代碼,我試着用var v = value.statistics.viewCount;
修改一下,但是沒有爲我工作,我試着找到一個答案但沒有任何結果...如何顯示viewCount YoutubeApi 3
$(document).ready(function() {
$($grid).masonry('reloadItems');
\t \t $($grid).masonry('layout');
\t $('.add1').click(function (event) {
event.preventDefault();
var searchTerm = $('#query').val();
getRequest(searchTerm);
\t \t
\t \t
});
});
function getRequest(searchTerm) {
url = 'https://www.googleapis.com/youtube/v3/search';
var params = {
part: 'snippet',
key: 'AIzaSyA8OmKcw2DMNkJicyCJ0vqvf90xgeH52zE',
q: searchTerm,
\t \t maxResults:10
};
$.getJSON(url, params, function (searchTerm) {
showResults(searchTerm);
});
}
function showResults(results) {
var html = "";
var entries = results.items;
$.each(entries, function (index, value) {
var title = value.snippet.title;
var thumbnail = value.snippet.thumbnails.high.url;
\t \t var v = value.statistics.viewCount;
\t \t
\t \t var description = value.snippet.description;
\t \t var videoID = value.id.videoId;
html += '<div class="item" title="' + title + '">' + '<img class= "vidth" id="' + videoID + '" src="' + thumbnail + '" ><div class="info"><p1>' + title+'</p1><hr><p2>'+description+'</p2><hr><p3>'+v+'</p3></div></div>';
});
$('.masonry').append(html);
\t $($grid).masonry('reloadItems');
$($grid).masonry('layout');
\t
}
沒有'viewCount'和搜索列表的資源,查看api – mpgn
認真不知道嗎?你能幫忙嗎? – user2205934
檢查此答案http://stackoverflow.com/a/35615051/2274530代碼檢索播放列表中的所有視頻的viewCount – mpgn