File size: 766 Bytes
1f074d8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
function getBlogService() {
  var service = OAuth2.createService('blog')
    .setAuthorizationBaseUrl('https://example.com/blog/api')
    .setTokenUrl('https://example.com/blog/api/token')
    .setClientId('YOUR_BLOG_CLIENT_ID')
    .setClientSecret('YOUR_BLOG_CLIENT_SECRET')
    .setCallbackFunction('authCallback')
    .setPropertyStore(PropertiesService.getUserProperties());
  return service;
}

function getImageData(lineData) {
  var blogService = getBlogService();
  var options = {
    'method': 'GET',
    'headers': {
      'Authorization': 'Bearer ' + blogService.getAccessToken()
    }
  };
  var response = UrlFetchApp.fetch('https://example.com/blog/api/images', options);
  var imageData = JSON.parse(response.getContentText());
  return imageData;
}