当我在搜索区域中放置任何关键字时,它会显示,但在我的php中,我总是会显示。我想在API中更改我想要的任何关键字并进行搜索。
<html>
<head>
<title>Google Search API</title>
</head>
<body>
<div id="content">
<input type="text" id="Query">
<button id="add">Search</button>
</div>
<script>
function hndlr(response) {
for (var i = 0; i < response.items.length; i++) {
var item = response.items[i];
// in production code, item.htmlTitle should have the HTML entities escaped.
document.getElementById("content").innerHTML += "<br>" + "<b>" + item.title + "</b>" + "<br>" + item.snippet + "<br>" + "<a href='" + item.link + "'>" + item.displayLink + "</a>";
}
}
</script>
<script id="searchme"></script>
<script type="text/javascript">
var search_query = 'https://www.googleapis.com/customsearch/v1?q=Query&cx=004123968310343535430%3Aaxml6iel9yo&key=AIzaSyDxPcphnrcN9_dfkRkFTbwkv44m1-HI1Hg&callback=hndlr';
document.getElementById('searchme').src = search_query;
</script>
</body>
</html>
&#13;