-
Notifications
You must be signed in to change notification settings - Fork 69
/
Yelp.gs
29 lines (26 loc) · 789 Bytes
/
Yelp.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
var CONSUMER_KEY = '...';
var CONSUMER_SECRET = '...';
var TOKEN = '...';
var TOKEN_SECRET = '...';
/**
* Authorizes and makes a request to the Yelp API.
*/
function run() {
var service = getService_();
var url = 'https://api.yelp.com/v2/search?term=food&location=San+Francisco';
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('Yelp')
// Set the consumer key and secret.
.setConsumerKey(CONSUMER_KEY)
.setConsumerSecret(CONSUMER_SECRET)
// Manually set the token and secret, as provided by the Yelp developer
// console.
.setAccessToken(TOKEN, TOKEN_SECRET);
}