0
<!doctype html>
<html>
<head>
<title>Search</title>
</head>
<body>
<div id="buttons">
<label> <input id="query" type="text"/><button id="search-button" onclick="keyWordsearch()">Search</button></label>
<div id="container">
<h1>Search Results</h1>
<ul id="results"></ul>
</div>
<script>
function keyWordsearch(){
gapi.client.setApiKey("AIzaSyCFdNzrcERfUCd1R5rk1h3JAjXNT9svi5g");
gapi.client.load('youtube', 'v3', function() {
makeRequest();
});
}
function makeRequest() {
var q = $('#query').val();
var request = gapi.client.youtube.search.list({
q: q,
part: 'snippet',
maxResults: 10
});
request.execute(function(response) {
$('#results').empty()
var srchItems = response.result.items;
$.each(srchItems, function(index, item) {
vidTitle = item.snippet.title;
$('#results').append('<pre>' + vidTitle + '</pre>');
})
})
}
</script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script src="https://apis.google.com/js/client.js?onload=googleApiClientReady"> </script>
</body>
</html>
所以我想要做的就是使用YouTube上使用Youtube API的关键字搜索视频。但是,youtube页面上提供的示例也需要“身份验证”。我需要在没有认证的情况下完成,只需使用API密钥即可。现在发生的事情是,当我按搜索按钮时,它什么也不做。我一直试图弄清楚自己,但我没有发现任何其他问题与我正在经历......帮助...Javascript搜索视频使用YouTube API通过API密钥
它正在为我工作没有任何问题,检查此 - http://prntscr.com/dfu9wn –