Insert Event in Google Calendar With Javascript -
my client id correct hidden in example.
i need posting event calendar. believe have code correct need else's eyes.
i need post event calendar.
scopes = ["https://www.googleapis.com/auth/calendar"] function checkauth() { gapi.auth.authorize( { 'client_id': client_id, 'scope': scopes.join(' '), 'immediate': true }, handleauthresult); } /** * handle response authorization server. * * @param {object} authresult authorization result. */ function handleauthresult(authresult) { var authorizediv = document.getelementbyid('authorize-div'); if (authresult && !authresult.error) { // hide auth ui, load client library. authorizediv.style.display = 'none'; loadcalendarapi(); } else { // show auth ui, allowing user initiate authorization // clicking authorize button. authorizediv.style.display = 'inline'; } } /** * initiate auth flow in response user clicking authorize button. * * @param {event} event button click event. */ function handleauthclick(event) { gapi.auth.authorize( {client_id: client_id, scope: scopes, immediate: false}, handleauthresult); return false; } /** * load google calendar client library. list upcoming events * once client library loaded. */ function loadcalendarapi() { gapi.client.load('calendar', 'v3', listupcomingevents); } /** * print summary , start datetime/date of next ten events in * authorized user's calendar. if no events found * appropriate message printed. */ function listupcomingevents() { var event = { "summary":"here" "description":"now" "start": { "datetime":"2016-04-21t12:00:00.000-07:00" "timezone":"america/los_angeles" } "end": { "datetime":"2016-04-21t12:30:00.000-07:00" "timezone":"america/los_angeles" } }; var request = gapi.client.calendar.events.insert({ 'calendarid': 'primary', 'resource': event }); request.execute(function(event) { appendpre('event created: ' + event.htmllink); }); }
Comments
Post a Comment