Visual FoxPro Google Calendar: Get Calendar

Back to Index

Returns an entry on the user's calendar list.
This example gets the calendar having the ID = "support@chilkatcloud.com".

Documentation: https://developers.google.com/google-apps/calendar/v3/reference/calendarList/get


LOCAL loRest
LOCAL lnSuccess
LOCAL loOauth2
LOCAL loSbJson
LOCAL loJson
LOCAL lcKind
LOCAL lcEtag
LOCAL lcId
LOCAL lcSummary
LOCAL lcTimeZone
LOCAL lcColorId
LOCAL lcBackgroundColor
LOCAL lcForegroundColor
LOCAL lnSelected
LOCAL lcAccessRole
LOCAL lnPrimary
LOCAL i
LOCAL lnCount_i
LOCAL lcMethod
LOCAL lnMinutes
LOCAL lcType

loRest = CreateObject('Chilkat_9_5_0.Rest')

*   Provide a previously obtained OAuth2 access token.
loOauth2 = CreateObject('Chilkat_9_5_0.OAuth2')
loOauth2.AccessToken = "OAUTH2_ACCESS_TOKEN"
loRest.SetAuthOAuth2(loOauth2)

lnSuccess = loRest.Connect("www.googleapis.com",443,1,1)
IF (lnSuccess <> 1) THEN
    ? loRest.LastErrorText
    RELEASE loRest
    RELEASE loOauth2
    CANCEL
ENDIF

loSbJson = CreateObject('Chilkat_9_5_0.StringBuilder')
lnSuccess = loRest.FullRequestNoBodySb("GET","/calendar/v3/users/me/calendarList/support@chilkatcloud.com",loSbJson)
IF (lnSuccess <> 1) THEN
    ? loRest.LastErrorText
    RELEASE loRest
    RELEASE loOauth2
    RELEASE loSbJson
    CANCEL
ENDIF

IF (loRest.ResponseStatusCode <> 200) THEN
    ? "Received error response code: " + STR(loRest.ResponseStatusCode)
    ? "Response body:"
    ? loSbJson.GetAsString()
    RELEASE loRest
    RELEASE loOauth2
    RELEASE loSbJson
    CANCEL
ENDIF

loJson = CreateObject('Chilkat_9_5_0.JsonObject')
loJson.LoadSb(loSbJson)

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

lcKind = loJson.StringOf("kind")
lcEtag = loJson.StringOf("etag")
lcId = loJson.StringOf("id")
lcSummary = loJson.StringOf("summary")
lcTimeZone = loJson.StringOf("timeZone")
lcColorId = loJson.StringOf("colorId")
lcBackgroundColor = loJson.StringOf("backgroundColor")
lcForegroundColor = loJson.StringOf("foregroundColor")
lnSelected = loJson.BoolOf("selected")
lcAccessRole = loJson.StringOf("accessRole")
lnPrimary = loJson.BoolOf("primary")
i = 0
lnCount_i = loJson.SizeOfArray("defaultReminders")
DO WHILE i < lnCount_i
    loJson.I = i
    lcMethod = loJson.StringOf("defaultReminders[i].method")
    lnMinutes = loJson.IntOf("defaultReminders[i].minutes")
    i = i + 1
ENDDO
i = 0
lnCount_i = loJson.SizeOfArray("notificationSettings.notifications")
DO WHILE i < lnCount_i
    loJson.I = i
    lcType = loJson.StringOf("notificationSettings.notifications[i].type")
    lcMethod = loJson.StringOf("notificationSettings.notifications[i].method")
    i = i + 1
ENDDO

? "Example Completed."

RELEASE loRest
RELEASE loOauth2
RELEASE loSbJson
RELEASE loJson

Sample JSON Response Body

{
  "kind": "calendar#calendarListEntry",
  "etag": "\"1465249947472000\"",
  "id": "support@chilkatcloud.com",
  "summary": "support@chilkatcloud.com",
  "timeZone": "America/Chicago",
  "colorId": "14",
  "backgroundColor": "#9fe1e7",
  "foregroundColor": "#000000",
  "selected": true,
  "accessRole": "owner",
  "defaultReminders": [
    {
      "method": "popup",
      "minutes": 10
    }
  ],
  "notificationSettings": {
    "notifications": [
      {
        "type": "eventCreation",
        "method": "email"
      },
      {
        "type": "eventChange",
        "method": "email"
      },
      {
        "type": "eventCancellation",
        "method": "email"
      },
      {
        "type": "eventResponse",
        "method": "email"
      }
    ]
  },
  "primary": true
}