Creating an event in Google Calendar
Hi,
I have listed below the deluge code snippet for creating an event to GoogleCalendar.
The script uses the PostUrl function to send header parameters and write XML Data in the request body.
Function for generating authoization heade
r
- string getGoogleAuthToken(string email, string passwd, string GoogleService)
- {
- accountType = "HOSTED_OR_GOOGLE";
- url = "https://www.google.com/accounts/ClientLogin?accountType=" + accountType + "&Email=" + email + "&Passwd=" + passwd + "&service=" + input.GoogleService; // Check Google service codes . For calendar, the value is cl.
- response = getUrl(url);
- authToken = response.getSuffix("Auth=").trim(); // Store this Authorization for subsequent request
- return authToken;
- }
Function for creating an event to GoogleCalendar.
- // eventname Tennis with John
- // month April
- // date 11
- // time 3pm-3:30pm
- void createEventInGoogle(string eventname,string month,int date,string time)
- {
- // Generating Auth Token
- GoogleAuthToken = thisapp.getGoogleAuthToken("xxxx@gmail.com", "yyyy","cl");
- // HeaderParams Included
- headerMap = { "Authorization" : "GoogleLogin auth=\"" + GoogleAuthToken + "\"", "Content-Type" : ("application/atom+xml") };
- event = eventname+" "+month+" "+date+" "+time;
- // XMLCalendarData Generating
- xmlCalendarData = "<entry xmlns='http://www.w3.org/2005/Atom' xmlns:gCal='http://schemas.google.com/gCal/2005'><content type='html'>"+event+"</content><gCal:quickadd value='true'/></entry>";
- // Creating an event to GoogleCalendar
- result = postUrl("https://www.google.com/calendar/feeds/default/private/full", xmlCalendarData, headerMap,false);
- info "Response Text " + result.get("responseText");
- info "Response Code " + result.get("responseCode");
- }
Please see the below sample application for your reference.
Thanks,
Saranya