Creating an event in Google Calendar

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
  1. string getGoogleAuthToken(string email, string passwd, string GoogleService)
  2. {
  3.     accountType = "HOSTED_OR_GOOGLE";
  4.     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.
  5.     response = getUrl(url);
  6.     authToken = response.getSuffix("Auth=").trim();  // Store this Authorization for subsequent request
  7.     return authToken;
  8. } 

Function for creating an event to GoogleCalendar.
  1. // eventname Tennis with John
  2. // month April
  3. // date 11
  4. // time 3pm-3:30pm
  5. void createEventInGoogle(string eventname,string month,int date,string time)
  6. {
  7.       // Generating Auth Token
  8.       GoogleAuthToken = thisapp.getGoogleAuthToken("xxxx@gmail.com", "yyyy","cl");
  9.       // HeaderParams Included
  10.       headerMap = { "Authorization" : "GoogleLogin auth=\"" + GoogleAuthToken + "\"", "Content-Type" : ("application/atom+xml") };
  11.       event = eventname+" "+month+" "+date+" "+time;
  12.       // XMLCalendarData Generating
  13.       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>";
  14.       // Creating an event to GoogleCalendar
  15.       result = postUrl("https://www.google.com/calendar/feeds/default/private/full", xmlCalendarData, headerMap,false); 
  16.       info "Response Text  " + result.get("responseText");
  17.       info "Response Code  " + result.get("responseCode");
  18. }
Please see the below sample application for your reference.


Thanks,
Saranya