Skip to content

Instantly share code, notes, and snippets.

@wendeehsu
Created November 18, 2021 15:40
Show Gist options
  • Save wendeehsu/e1318e28cf659e9701488d378a40b263 to your computer and use it in GitHub Desktop.
Save wendeehsu/e1318e28cf659e9701488d378a40b263 to your computer and use it in GitHub Desktop.
function getReviews(locationId = 'YOUR_LOCATION_ID') {
var service = getService();
if (service.hasAccess()) {
var url = 'https://mybusiness.googleapis.com/v4/accounts/'+ accountId +'/locations/'+locationId+'/reviews';
Logger.log(url);
var response = UrlFetchApp.fetch(url, {
headers: {
Authorization: 'Bearer ' + service.getAccessToken()
}
});
var result = JSON.parse(response.getContentText());
Logger.log(JSON.stringify(result, null, 2));
} else {
var authorizationUrl = service.getAuthorizationUrl();
Logger.log('Open the following URL and re-run the script: %s', authorizationUrl);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment