Google Calendar API Sample
googlecalendar
tomoyukikashiro
Developer Site
https://developers.google.com/api-client-library/javascript/
Client Repository
https://code.google.com/p/google-api-javascript-client/
How to call Calendar API
Create Google App
- access Developer Console Site.
- click
CREATE PROJECT
button. - click
APIs & auth > APIs
menu in left column. - trun on
Calendar API
button. - click
Credential
menu in left column. - copy
client ID
inClient ID for web application
section.
Create HTML
load Javascript client.onload
parameter is to set a callback method name which will be called when client is initialized.
<script src="https://apis.google.com/js/client.js?onload=onLoadGapiClient"></script>
Auth
Following method is to auth.
You can check about calendar auth information and auth method.
var config = {
'client_id': clientId,
'scope' : 'https://www.googleapis.com/auth/calendar',
'immediate': false
};
gapi.auth.authorize(config, $.proxy(this.handleAuthResult, this));
Get Calendar Information
Following method is to get calendar information.
You can check about client method (gapi.client.calendar
)
var config = {
minAccessRole: 'owner'
},
request = gapi.client.calendar.calendarList.list(config);
request.execute(function(res){
console.log(res); // calendar informatino :)
});
My Sample Code
here! :)