Created
June 8, 2012 10:02
-
-
Save nobuhito/2894802 to your computer and use it in GitHub Desktop.
GoogleCalendarへのインポートが動かない
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 auth_user = Session.getActiveUser().getEmail(); | |
var oauth = UrlFetchApp.addOAuthService('calendar'); | |
oauth.setConsumerKey("XXXXXXXXXXXXXXXXXXX"); | |
oauth.setConsumerSecret("XXXXXXXXXXXXXXXXXXXXXXX"); | |
oauth.setRequestTokenUrl("https://www.google.com/accounts/OAuthGetRequestToken?scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcalendar"); | |
oauth.setAuthorizationUrl("https://www.google.com/accounts/OAuthAuthorizeToken"); | |
oauth.setAccessTokenUrl("https://www.google.com/accounts/OAuthGetAccessToken"); | |
var payload = { | |
'summary': 'Appointment', | |
'start': { | |
'dateTime': '2012-06-09T10:00:00.000-07:00' | |
}, | |
'end': { | |
'dateTime': '2012-06-09T10:25:00.000-07:00' | |
}, | |
'iCalUID': 'originalUID', | |
'attenders': [ | |
{ | |
'email': 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', | |
} | |
], | |
'reminders':{ | |
'overrides': [ | |
{ | |
'method': 'email', | |
'minutes': '10' | |
} | |
] | |
} | |
}; | |
var options = { | |
"method" : "post", | |
"oAuthServiceName" : 'calendar', | |
"oAuthUseToken" : "if_available", | |
"payload": payload, | |
"contentType": "application/json" | |
}; | |
var url = 'https://www.googleapis.com/calendar/v3/calendars/XXXXXXXXXXXXXXXXXXXXXXXX/events/import'; | |
var res = UrlFetchApp.fetch(url, options); | |
var test = res.getContentText("UTF-8"); | |
Logger.log(test); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment