-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
52 lines (51 loc) · 1.44 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<html>
<head>
<title>Bonjour Bruno!</title>
</head>
<script src="https://apis.google.com/js/api.js"></script>
<script>
/**
* Sample JavaScript code for search.cse.list
* See instructions for running APIs Explorer code samples locally:
* https://developers.google.com/explorer-help/code-samples#javascript
*/
function loadClient() {
gapi.client.setApiKey(API_KEY);
return gapi.client
.load(
"https://content.googleapis.com/discovery/v1/apis/customsearch/v1/rest"
)
.then(
function () {
console.log("GAPI client loaded for API");
execute();
},
function (err) {
console.error("Error loading GAPI client for API", err);
}
);
}
// Make sure the client is loaded before calling this method.
function execute() {
return gapi.client.search.cse
.list({
cx: SEARCH_ENGINE_ID,
q: "Bruno Le Maire",
searchType: "image",
imgSize: "LARGE",
fileType: "png",
})
.then(
function (response) {
// Handle the results here (response.result has the parsed body).
console.log("Response", response);
},
function (err) {
console.error("Execute error", err);
}
);
}
gapi.load("client");
</script>
<body onload="loadClient()"></body>
</html>