By Ryan Aunur Rassyid
Simply create RESTful API with Google Script and store it to Google SpreadSheet like a Pro.
/* | |
* Copyright 2017 Mohsen Mesgarpour | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software |
/** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * | |
* httpGetTemplate.gs | |
* | |
* A pair of template functions for external host communication with | |
* UrlFetchApp, including parameter encoding and error handling. | |
* | |
* From: gist.github.com/mogsdad/a76c32231a2b91ff8b59 | |
* | |
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | |
/** | |
* Sends an email using the contents of a Google Document as the body. | |
*/ | |
function sendDocument(documentId, recipient, subject) { | |
var html = convertToHtml(documentId); | |
html = inlineCss(html); | |
GmailApp.sendEmail(recipient, subject, null, { | |
htmlBody: html | |
}); | |
} |
var KEY = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'; //developer key , get from https://code.google.com/apis/console/b/1/ | |
var FILE_ID = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'; // drive file id | |
function convertDocuments2() { | |
var oauthConfig = UrlFetchApp.addOAuthService('drive'); | |
//Create oauth config for drive api | |
var scope = 'https://www.googleapis.com/auth/drive'; | |
oauthConfig.setConsumerKey('anonymous'); | |
oauthConfig.setConsumerSecret('anonymous'); |