如何使用part:snippet和contentDetails?我想获得持续时间,只有音乐视频,标题和观看次数.. 请帮帮我。
function keyWordsearch() {
gapi.client.setApiKey("MY_API_KEY");
gapi.client.load('youtube', 'v3', function () {
var q = $('#query').val();
$("#result").empty();
var request = gapi.client.youtube.search.list({
q: q,
part: 'snippet',
maxResults: 5,
});
request.execute(function (response) {
for (var i = 0; i < response.items.length; i++) {
var id = response.items[i].id.videoId;
var name = response.items[i].snippet.title;
$('#result').html($('#result').html() + "<li><a href='http://www.youtube.com/watch?v=" + id + "'>" + name + " </a></li>");
}
$('#result').html($('#result').html() + '</ul>');
});
});
}
</script>
<script src="https://apis.google.com/js/client.js?onload=onLoadCallback"></script>