DataFlex 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


Use ChilkatAx-9.5.0-win32.pkg

Procedure Test
    Handle hoRest
    Boolean iSuccess
    Variant vOauth2
    Handle hoOauth2
    Variant vSbJson
    Handle hoSbJson
    Handle hoJson
    String sKind
    String sEtag
    String sSummary
    String sUpdated
    String sTimeZone
    String sAccessRole
    String sNextSyncToken
    Integer i
    Integer iCount_i
    String sMethod
    Integer iMinutes
    String sId
    String sStatus
    String sHtmlLink
    String sCreated
    String sDescription
    String sLocation
    String sCreatorEmail
    Boolean iCreatorSelf
    String sOrganizerEmail
    Boolean iOrganizerSelf
    String sStartDateTime
    String sStartTimeZone
    String sEndDateTime
    String sEndTimeZone
    String sRecurringEventId
    String sOriginalStartTimeDateTime
    String sOriginalStartTimeTimeZone
    String sICalUID
    Integer iSequence
    String sHangoutLink
    Boolean iRemindersUseDefault
    Integer j
    Integer iCount_j
    String sTemp1
    Integer iTemp1

    Get Create (RefClass(cComChilkatRest)) To hoRest
    If (Not(IsComObjectCreated(hoRest))) Begin
        Send CreateComObject of hoRest
    End

    //   Provide a previously obtained OAuth2 access token.
    Get Create (RefClass(cComChilkatOAuth2)) To hoOauth2
    If (Not(IsComObjectCreated(hoOauth2))) Begin
        Send CreateComObject of hoOauth2
    End
    Set ComAccessToken Of hoOauth2 To "OAUTH2_ACCESS_TOKEN"
    Get pvComObject of hoOauth2 to vOauth2
    Get ComSetAuthOAuth2 Of hoRest vOauth2 To iSuccess

    Get ComConnect Of hoRest "www.googleapis.com" 443 True True To iSuccess
    If (iSuccess <> True) Begin
        Get ComLastErrorText Of hoRest To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get Create (RefClass(cComChilkatStringBuilder)) To hoSbJson
    If (Not(IsComObjectCreated(hoSbJson))) Begin
        Send CreateComObject of hoSbJson
    End
    Get pvComObject of hoSbJson to vSbJson
    Get ComFullRequestNoBodySb Of hoRest "GET" "/calendar/v3/calendars/support@chilkatcloud.com/events/6li3bfqqq65edprt4ms6vdld2j/instances" vSbJson To iSuccess
    If (iSuccess <> True) Begin
        Get ComLastErrorText Of hoRest To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get ComResponseStatusCode Of hoRest To iTemp1
    If (iTemp1 <> 200) Begin
        Get ComResponseStatusCode Of hoRest To iTemp1
        Showln "Received error response code: " iTemp1
        Showln "Response body:"
        Get ComGetAsString Of hoSbJson To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get Create (RefClass(cComChilkatJsonObject)) To hoJson
    If (Not(IsComObjectCreated(hoJson))) Begin
        Send CreateComObject of hoJson
    End
    Get pvComObject of hoSbJson to vSbJson
    Get ComLoadSb Of hoJson vSbJson To iSuccess

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

    Get ComStringOf Of hoJson "kind" To sKind
    Get ComStringOf Of hoJson "etag" To sEtag
    Get ComStringOf Of hoJson "summary" To sSummary
    Get ComStringOf Of hoJson "updated" To sUpdated
    Get ComStringOf Of hoJson "timeZone" To sTimeZone
    Get ComStringOf Of hoJson "accessRole" To sAccessRole
    Get ComStringOf Of hoJson "nextSyncToken" To sNextSyncToken
    Move 0 To i
    Get ComSizeOfArray Of hoJson "defaultReminders" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJson To i
        Get ComStringOf Of hoJson "defaultReminders[i].method" To sMethod
        Get ComIntOf Of hoJson "defaultReminders[i].minutes" To iMinutes
        Move i + 1 To i
    Loop

    Move 0 To i
    Get ComSizeOfArray Of hoJson "items" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJson To i
        Get ComStringOf Of hoJson "items[i].kind" To sKind
        Get ComStringOf Of hoJson "items[i].etag" To sEtag
        Get ComStringOf Of hoJson "items[i].id" To sId
        Get ComStringOf Of hoJson "items[i].status" To sStatus
        Get ComStringOf Of hoJson "items[i].htmlLink" To sHtmlLink
        Get ComStringOf Of hoJson "items[i].created" To sCreated
        Get ComStringOf Of hoJson "items[i].updated" To sUpdated
        Get ComStringOf Of hoJson "items[i].summary" To sSummary
        Get ComStringOf Of hoJson "items[i].description" To sDescription
        Get ComStringOf Of hoJson "items[i].location" To sLocation
        Get ComStringOf Of hoJson "items[i].creator.email" To sCreatorEmail
        Get ComBoolOf Of hoJson "items[i].creator.self" To iCreatorSelf
        Get ComStringOf Of hoJson "items[i].organizer.email" To sOrganizerEmail
        Get ComBoolOf Of hoJson "items[i].organizer.self" To iOrganizerSelf
        Get ComStringOf Of hoJson "items[i].start.dateTime" To sStartDateTime
        Get ComStringOf Of hoJson "items[i].start.timeZone" To sStartTimeZone
        Get ComStringOf Of hoJson "items[i].end.dateTime" To sEndDateTime
        Get ComStringOf Of hoJson "items[i].end.timeZone" To sEndTimeZone
        Get ComStringOf Of hoJson "items[i].recurringEventId" To sRecurringEventId
        Get ComStringOf Of hoJson "items[i].originalStartTime.dateTime" To sOriginalStartTimeDateTime
        Get ComStringOf Of hoJson "items[i].originalStartTime.timeZone" To sOriginalStartTimeTimeZone
        Get ComStringOf Of hoJson "items[i].iCalUID" To sICalUID
        Get ComIntOf Of hoJson "items[i].sequence" To iSequence
        Get ComStringOf Of hoJson "items[i].hangoutLink" To sHangoutLink
        Get ComBoolOf Of hoJson "items[i].reminders.useDefault" To iRemindersUseDefault
        Move 0 To j
        Get ComSizeOfArray Of hoJson "items[i].reminders.overrides" To iCount_j
        While (j < iCount_j)
            Set ComJ Of hoJson To j
            Get ComStringOf Of hoJson "items[i].reminders.overrides[j].method" To sMethod
            Get ComIntOf Of hoJson "items[i].reminders.overrides[j].minutes" To iMinutes
            Move j + 1 To j
        Loop

        Move i + 1 To i
    Loop

    Showln "Example Completed."


End_Procedure

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
          }
        ]
      }
    }
  ]
}