Reputation: 91
I'm using this Google App script
// Reference: https://www.labnol.org/code/20068-blogger-api-with-google-apps-script
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);
}
}
How can I import the values that are in the Logger.log into my sheet.
Upvotes: 0
Views: 156
Reputation: 2014
You have to change the Logger.log() for appendRow(). In your case you have to set the sheet you want to insert the values:
var ss = SpreadsheetApp.getActiveSpreadsheet(); // Gets the Active Spreadsheet
var ss = SpreadsheetApp.openById("ID OF THE SPREADSHEET"); // Alternative way of getting a Spreadsheet
var sheet = ss.getSheets()[0]; // Gets the first sheet
var sheet = ss.getSheets().getSheetByName("Sheet4"); // Gets the sheet with the name Sheet4
Once you have the Spreadsheet you want, inside the for loop, you insert the values:
sheet.appendRow([json.items[i].id, json.items[i].name, json.items[i].url]);
Upvotes: 1