Skip to content

Google Apps Script to blogger API #121

@catafest

Description

@catafest

Expected Behavior

I try to access the https://developers.google.com/apis-explorer/#search/stats/m/blogger/v3/blogger.pageViews.get with Google Apps Script.
Sample URL:
Description:

function bloggerAPI() {
  
  var api = "https://www.googleapis.com/blogger/v3/users/self/blogs";
  
  var headers = {
    "Authorization": "Bearer " + getService().getAccessToken()
  };
  
  var options = {
    "headers": headers,
    "method" : "GET",
    "muteHttpExceptions": true
  };
  
  var response = UrlFetchApp.fetch(api, options);
  
  var json = JSON.parse(response.getContentText());
  
  for (var i in json.items) {
    Logger.log("[%s] %s %s", json.items[i].id, json.items[i].name, json.items[i].url); 
  } 
}

Actual Behavior

ReferenceError: "getService" is not defined. (line 18, file "Code")

Steps to Reproduce the Problem

  1. write the code
  2. the project is link for authorization
    1.I got the error

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions