This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function myFunction() { | |
//oauth の設定 | |
var oauth = UrlFetchApp.addOAuthService(Session.getActiveUser().getEmail()); | |
oauth.setConsumerKey("anonymous"); //ちゃんとしたのを使ったほうがいいとおもふ | |
oauth.setConsumerSecret("anonymous"); //ちゃんとしたのを使ったほうがいいとおもふ | |
oauth.setRequestTokenUrl("https://www.google.com/accounts/OAuthGetRequestToken?scope=https%3A%2F%2Fwww.google.com%2Fcalendar%2Ffeeds%2F"); | |
oauth.setAuthorizationUrl("https://www.google.com/accounts/OAuthAuthorizeToken"); | |
oauth.setAccessTokenUrl("https://www.google.com/accounts/OAuthGetAccessToken"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function twoleggedOAuth() { | |
var action = "https://www.google.com/calendar/feeds/default/private/full?xoauth_requestor_id={user mail address}"; | |
var accessor = { consumerSecret: '{consumerSecret}' }; | |
var message = { method: 'get', action: action, parameters: {}, }; | |
OAuth.setParameter(message, 'oauth_version', '1.0'); | |
OAuth.setParameter(message, 'oauth_nonce', OAuth.nonce(32)); | |
OAuth.setParameter(message, 'oauth_timestamp', OAuth.timestamp()); | |
OAuth.setParameter(message, 'oauth_consumer_key', '{your domain}'); | |
OAuth.SignatureMethod.sign(message, accessor); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var projectId = ScriptProperties.getProperty("projectId"); | |
function プロジェクトの取得() { | |
var list = BigQuery.Projects.list(); | |
Logger.log(list); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function グループ() { | |
// {ユーザ名}@{ドメイン名}のユーザ名の部分を指定 | |
var user = UserManager.getUser("k-ohashi"); | |
//全グループの取得 | |
var groups = GroupsManager.getAllGroups(); | |
for(var i = 0; i < groups.length; i++) { | |
Logger.log(groups[i].getName()); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function BigQueryLiveDemo() { | |
//6219749 | |
var list = BigQuery.Projects.list(); | |
Logger.log(list); | |
//プロジェクトIDの取得 | |
var projectId = list.getProjects()[0].getId(); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var KEY = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'; //developer key , get on https://code.google.com/apis/console/ and set enable the Drive API. | |
/** | |
* Convert from Excel data to Spreadsheet | |
* @param {Blob} excelFile the excel blob data. | |
* @param {String} filename file name on uploading drive | |
* @return {Spreadsheet} spreadsheet instance. | |
**/ | |
function convert2Spreadsheet(excelFile, filename) { | |
var oauthConfig = UrlFetchApp.addOAuthService('drive'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function writeSpreadsheetDataAsCsv() { | |
//Spreadsheetからデータ取得 | |
var data = SpreadsheetApp.openById('id').getSheetByName('sheetName').getDataRange().getValues(); | |
//二次配列→カンマ区切り文字列の一次配列 | |
var writeDataArray = []; | |
for(var r = 0; r < data.length; r++) { | |
var row = data[r]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function createNewForm() { | |
var form = FormApp.create('フォームのタイトル'); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function myFunction() { | |
var option = googleOAuth_(); | |
option.method = "post"; | |
option.contentType = 'application/json'; | |
option.payload = JSON.stringify({ | |
"query": | |
{ | |
"kinds": | |
[ |
OlderNewer