-
Notifications
You must be signed in to change notification settings - Fork 69
/
Semantics3.gs
30 lines (27 loc) · 799 Bytes
/
Semantics3.gs
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
var API_KEY = '...';
var API_SECRET = '...';
/**
* Authorizes and makes a request to the Semantics3 API.
*/
function run() {
var service = getService_();
var query = encodeURIComponent(JSON.stringify({
search: 'iPhone'
}));
var url = 'https://api.semantics3.com/v1/products?q=' + query;
var response = service.fetch(url);
var result = JSON.parse(response.getContentText());
Logger.log(JSON.stringify(result, null, 2));
}
/**
* Configures the service.
*/
function getService_() {
return OAuth1.createService('Semantics3')
// Set the consumer key and secret.
.setConsumerKey(API_KEY)
.setConsumerSecret(API_SECRET)
// Manually set the token and secret to the empty string, since the API
// uses 1-legged OAuth.
.setAccessToken('', '');
}