Tcl Google Calendar: Get Instances of a Recurring Event

Back to Index

Returns instances of the specified recurring event.
This example gets instances for an event from the calendar having the ID = "support@chilkatcloud.com", where the event ID equals "6li3bfqqq65edprt4ms6vdld2j"

Documentation: https://developers.google.com/google-apps/calendar/v3/reference/events/instances



load ./chilkat.dll

set rest [new_CkRest]

#   Provide a previously obtained OAuth2 access token.
set oauth2 [new_CkOAuth2]

CkOAuth2_put_AccessToken $oauth2 "OAUTH2_ACCESS_TOKEN"
CkRest_SetAuthOAuth2 $rest $oauth2

set success [CkRest_Connect $rest "www.googleapis.com" 443 1 1]
if {[expr $success != 1]} then {
    puts [CkRest_lastErrorText $rest]
    delete_CkRest $rest
    delete_CkOAuth2 $oauth2
    exit
}

set sbJson [new_CkStringBuilder]

set success [CkRest_FullRequestNoBodySb $rest "GET" "/calendar/v3/calendars/support@chilkatcloud.com/events/6li3bfqqq65edprt4ms6vdld2j/instances" $sbJson]
if {[expr $success != 1]} then {
    puts [CkRest_lastErrorText $rest]
    delete_CkRest $rest
    delete_CkOAuth2 $oauth2
    delete_CkStringBuilder $sbJson
    exit
}

if {[expr [CkRest_ResponseStatusCode $rest] != 200]} then {
    puts "Received error response code: [CkRest_ResponseStatusCode $rest]"
    puts "Response body:"
    puts [CkStringBuilder_getAsString $sbJson]
    delete_CkRest $rest
    delete_CkOAuth2 $oauth2
    delete_CkStringBuilder $sbJson
    exit
}

set json [new_CkJsonObject]

CkJsonObject_LoadSb $json $sbJson

#  The following code parses the JSON response.
#  A sample JSON response is shown below the sample code.

set kind [CkJsonObject_stringOf $json "kind"]
set etag [CkJsonObject_stringOf $json "etag"]
set summary [CkJsonObject_stringOf $json "summary"]
set updated [CkJsonObject_stringOf $json "updated"]
set timeZone [CkJsonObject_stringOf $json "timeZone"]
set accessRole [CkJsonObject_stringOf $json "accessRole"]
set nextSyncToken [CkJsonObject_stringOf $json "nextSyncToken"]
set i 0
set count_i [CkJsonObject_SizeOfArray $json "defaultReminders"]
while {[expr $i < $count_i]} {
    CkJsonObject_put_I $json $i
    set method [CkJsonObject_stringOf $json "defaultReminders[i].method"]
    set minutes [CkJsonObject_IntOf $json "defaultReminders[i].minutes"]
    set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $json "items"]
while {[expr $i < $count_i]} {
    CkJsonObject_put_I $json $i
    set kind [CkJsonObject_stringOf $json "items[i].kind"]
    set etag [CkJsonObject_stringOf $json "items[i].etag"]
    set id [CkJsonObject_stringOf $json "items[i].id"]
    set status [CkJsonObject_stringOf $json "items[i].status"]
    set htmlLink [CkJsonObject_stringOf $json "items[i].htmlLink"]
    set created [CkJsonObject_stringOf $json "items[i].created"]
    set updated [CkJsonObject_stringOf $json "items[i].updated"]
    set summary [CkJsonObject_stringOf $json "items[i].summary"]
    set description [CkJsonObject_stringOf $json "items[i].description"]
    set location [CkJsonObject_stringOf $json "items[i].location"]
    set creatorEmail [CkJsonObject_stringOf $json "items[i].creator.email"]
    set creatorSelf [CkJsonObject_BoolOf $json "items[i].creator.self"]
    set organizerEmail [CkJsonObject_stringOf $json "items[i].organizer.email"]
    set organizerSelf [CkJsonObject_BoolOf $json "items[i].organizer.self"]
    set startDateTime [CkJsonObject_stringOf $json "items[i].start.dateTime"]
    set startTimeZone [CkJsonObject_stringOf $json "items[i].start.timeZone"]
    set endDateTime [CkJsonObject_stringOf $json "items[i].end.dateTime"]
    set endTimeZone [CkJsonObject_stringOf $json "items[i].end.timeZone"]
    set recurringEventId [CkJsonObject_stringOf $json "items[i].recurringEventId"]
    set originalStartTimeDateTime [CkJsonObject_stringOf $json "items[i].originalStartTime.dateTime"]
    set originalStartTimeTimeZone [CkJsonObject_stringOf $json "items[i].originalStartTime.timeZone"]
    set iCalUID [CkJsonObject_stringOf $json "items[i].iCalUID"]
    set sequence [CkJsonObject_IntOf $json "items[i].sequence"]
    set hangoutLink [CkJsonObject_stringOf $json "items[i].hangoutLink"]
    set remindersUseDefault [CkJsonObject_BoolOf $json "items[i].reminders.useDefault"]
    set j 0
    set count_j [CkJsonObject_SizeOfArray $json "items[i].reminders.overrides"]
    while {[expr $j < $count_j]} {
        CkJsonObject_put_J $json $j
        set method [CkJsonObject_stringOf $json "items[i].reminders.overrides[j].method"]
        set minutes [CkJsonObject_IntOf $json "items[i].reminders.overrides[j].minutes"]
        set j [expr $j + 1]
    }
    set i [expr $i + 1]
}

puts "Example Completed."

delete_CkRest $rest
delete_CkOAuth2 $oauth2
delete_CkStringBuilder $sbJson
delete_CkJsonObject $json

Sample JSON Response Body

{
  "kind": "calendar#events",
  "etag": "\"p33se7k7armnte0g\"",
  "summary": "support@chilkatcloud.com",
  "updated": "2017-11-08T19:40:49.131Z",
  "timeZone": "America/Chicago",
  "accessRole": "owner",
  "defaultReminders": [
    {
      "method": "popup",
      "minutes": 10
    }
  ],
  "nextSyncToken": "CPjj0Ordr9cCEPjj0Ordr9cCGAU=",
  "items": [
    {
      "kind": "calendar#event",
      "etag": "\"3020339874608000\"",
      "id": "6li3bfqqq65edprt4ms6vdld2j_20171111T000000Z",
      "status": "confirmed",
      "htmlLink": "https://www.google.com/calendar/event?eid=NmxpM2JmcXFxNjVlZHBydDRtczZ2ZGxkMmpfMjAxNzExMTFUMDAwMDAwWiBzdXBwb3J0QGNoaWxrYXRjbG91ZC5jb20",
      "created": "2017-11-08T19:35:30.000Z",
      "updated": "2017-11-08T19:40:49.019Z",
      "summary": "TGIF Happy Hour",
      "description": "Friday Night Happy Hour",
      "location": "Shannon's Irish Pub, 428 N Main St, Glen Ellyn, IL 60137, USA",
      "creator": {
        "email": "support@chilkatcloud.com",
        "self": true
      },
      "organizer": {
        "email": "support@chilkatcloud.com",
        "self": true
      },
      "start": {
        "dateTime": "2017-11-10T18:00:00-06:00",
        "timeZone": "America/Chicago"
      },
      "end": {
        "dateTime": "2017-11-10T19:00:00-06:00",
        "timeZone": "America/Chicago"
      },
      "recurringEventId": "6li3bfqqq65edprt4ms6vdld2j",
      "originalStartTime": {
        "dateTime": "2017-11-10T18:00:00-06:00",
        "timeZone": "America/Chicago"
      },
      "iCalUID": "6li3bfqqq65edprt4ms6vdld2j@google.com",
      "sequence": 1,
      "hangoutLink": "https://plus.google.com/hangouts/_/chilkatcloud.com/support?hceid=c3VwcG9ydEBjaGlsa2F0Y2xvdWQuY29t.6li3bfqqq65edprt4ms6vdld2j",
      "reminders": {
        "useDefault": false,
        "overrides": [
          {
            "method": "popup",
            "minutes": 180
          }
        ]
      }
    },
    {
      "kind": "calendar#event",
      "etag": "\"3020339874608000\"",
      "id": "6li3bfqqq65edprt4ms6vdld2j_20171118T000000Z",
      "status": "confirmed",
      "htmlLink": "https://www.google.com/calendar/event?eid=NmxpM2JmcXFxNjVlZHBydDRtczZ2ZGxkMmpfMjAxNzExMThUMDAwMDAwWiBzdXBwb3J0QGNoaWxrYXRjbG91ZC5jb20",
      "created": "2017-11-08T19:35:30.000Z",
      "updated": "2017-11-08T19:40:49.019Z",
      "summary": "TGIF Happy Hour",
      "description": "Friday Night Happy Hour",
      "location": "Shannon's Irish Pub, 428 N Main St, Glen Ellyn, IL 60137, USA",
      "creator": {
        "email": "support@chilkatcloud.com",
        "self": true
      },
      "organizer": {
        "email": "support@chilkatcloud.com",
        "self": true
      },
      "start": {
        "dateTime": "2017-11-17T18:00:00-06:00",
        "timeZone": "America/Chicago"
      },
      "end": {
        "dateTime": "2017-11-17T19:00:00-06:00",
        "timeZone": "America/Chicago"
      },
      "recurringEventId": "6li3bfqqq65edprt4ms6vdld2j",
      "originalStartTime": {
        "dateTime": "2017-11-17T18:00:00-06:00",
        "timeZone": "America/Chicago"
      },
      "iCalUID": "6li3bfqqq65edprt4ms6vdld2j@google.com",
      "sequence": 1,
      "hangoutLink": "https://plus.google.com/hangouts/_/chilkatcloud.com/support?hceid=c3VwcG9ydEBjaGlsa2F0Y2xvdWQuY29t.6li3bfqqq65edprt4ms6vdld2j",
      "reminders": {
        "useDefault": false,
        "overrides": [
          {
            "method": "popup",
            "minutes": 180
          }
        ]
      }
    },
    {
      "kind": "calendar#event",
      "etag": "\"3020339874608000\"",
      "id": "6li3bfqqq65edprt4ms6vdld2j_20171125T000000Z",
      "status": "confirmed",
      "htmlLink": "https://www.google.com/calendar/event?eid=NmxpM2JmcXFxNjVlZHBydDRtczZ2ZGxkMmpfMjAxNzExMjVUMDAwMDAwWiBzdXBwb3J0QGNoaWxrYXRjbG91ZC5jb20",
      "created": "2017-11-08T19:35:30.000Z",
      "updated": "2017-11-08T19:40:49.019Z",
      "summary": "TGIF Happy Hour",
      "description": "Friday Night Happy Hour",
      "location": "Shannon's Irish Pub, 428 N Main St, Glen Ellyn, IL 60137, USA",
      "creator": {
        "email": "support@chilkatcloud.com",
        "self": true
      },
      "organizer": {
        "email": "support@chilkatcloud.com",
        "self": true
      },
      "start": {
        "dateTime": "2017-11-24T18:00:00-06:00",
        "timeZone": "America/Chicago"
      },
      "end": {
        "dateTime": "2017-11-24T19:00:00-06:00",
        "timeZone": "America/Chicago"
      },
      "recurringEventId": "6li3bfqqq65edprt4ms6vdld2j",
      "originalStartTime": {
        "dateTime": "2017-11-24T18:00:00-06:00",
        "timeZone": "America/Chicago"
      },
      "iCalUID": "6li3bfqqq65edprt4ms6vdld2j@google.com",
      "sequence": 1,
      "hangoutLink": "https://plus.google.com/hangouts/_/chilkatcloud.com/support?hceid=c3VwcG9ydEBjaGlsa2F0Y2xvdWQuY29t.6li3bfqqq65edprt4ms6vdld2j",
      "reminders": {
        "useDefault": false,
        "overrides": [
          {
            "method": "popup",
            "minutes": 180
          }
        ]
      }
    },
    {
      "kind": "calendar#event",
      "etag": "\"3020339874608000\"",
      "id": "6li3bfqqq65edprt4ms6vdld2j_20171202T000000Z",
      "status": "confirmed",
      "htmlLink": "https://www.google.com/calendar/event?eid=NmxpM2JmcXFxNjVlZHBydDRtczZ2ZGxkMmpfMjAxNzEyMDJUMDAwMDAwWiBzdXBwb3J0QGNoaWxrYXRjbG91ZC5jb20",
      "created": "2017-11-08T19:35:30.000Z",
      "updated": "2017-11-08T19:40:49.019Z",
      "summary": "TGIF Happy Hour",
      "description": "Friday Night Happy Hour",
      "location": "Shannon's Irish Pub, 428 N Main St, Glen Ellyn, IL 60137, USA",
      "creator": {
        "email": "support@chilkatcloud.com",
        "self": true
      },
      "organizer": {
        "email": "support@chilkatcloud.com",
        "self": true
      },
      "start": {
        "dateTime": "2017-12-01T18:00:00-06:00",
        "timeZone": "America/Chicago"
      },
      "end": {
        "dateTime": "2017-12-01T19:00:00-06:00",
        "timeZone": "America/Chicago"
      },
      "recurringEventId": "6li3bfqqq65edprt4ms6vdld2j",
      "originalStartTime": {
        "dateTime": "2017-12-01T18:00:00-06:00",
        "timeZone": "America/Chicago"
      },
      "iCalUID": "6li3bfqqq65edprt4ms6vdld2j@google.com",
      "sequence": 1,
      "hangoutLink": "https://plus.google.com/hangouts/_/chilkatcloud.com/support?hceid=c3VwcG9ydEBjaGlsa2F0Y2xvdWQuY29t.6li3bfqqq65edprt4ms6vdld2j",
      "reminders": {
        "useDefault": false,
        "overrides": [
          {
            "method": "popup",
            "minutes": 180
          }
        ]
      }
    }
  ]
}