AutoIt
AutoIt
Outlook Calendar List Events
See more Outlook Calendar Examples
Retrieve a list of events in a calendar.Chilkat AutoIt Downloads
Local $bSuccess = False
; This example requires the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.
$oHttp = ObjCreate("Chilkat.Http")
; Use your previously obtained access token here: Get Outlook Calendar OAuth2 Access Token (Azure AD v2.0 Endpoint).
$oJsonToken = ObjCreate("Chilkat.JsonObject")
$bSuccess = $oJsonToken.LoadFile("qa_data/tokens/outlookCalendar.json")
If ($bSuccess = False) Then
ConsoleWrite($oJsonToken.LastErrorText & @CRLF)
Exit
EndIf
$oHttp.AuthToken = $oJsonToken.StringOf("access_token")
; Specify the ID of the calendar to list.
Local $sCalendarId = "AQMkADAwATM0MDAAMS1iNTcwLWI2NTEtMDACLTAwCgBGAAADsVyfxjDU406Ic4X7ill8xAcA5_vF7TKKdE6bGCRqXyl2PQAAAgEGAAAA5_vF7TKKdE6bGCRqXyl2PQAAAiCsAAAA"
$oHttp.SetUrlVar("id",$sCalendarId)
; To list the events in the default calendar, use the following URL: https://graph.microsoft.com/v1.0/me/calendars/events
$oResp = ObjCreate("Chilkat.HttpResponse")
$bSuccess = $oHttp.HttpNoBody("GET","https://graph.microsoft.com/v1.0/me/calendars/{$id}/events",$oResp)
If ($bSuccess = False) Then
ConsoleWrite($oHttp.LastErrorText & @CRLF)
Exit
EndIf
ConsoleWrite("Response status code = " & $oResp.StatusCode & @CRLF)
; The HTTP request succeeded if the response status code = 200.
If ($oResp.StatusCode <> 200) Then
ConsoleWrite($oResp.BodyStr & @CRLF)
ConsoleWrite("Failed" & @CRLF)
Exit
EndIf
$oJson = ObjCreate("Chilkat.JsonObject")
$oJson.Load($oResp.BodyStr)
$oJson.EmitCompact = False
ConsoleWrite($oJson.Emit() & @CRLF)
; Here is a sample response:
; Use this online tool to generate parsing code from sample JSON:
; Generate Parsing Code from JSON
; {
; "value": [
; {
; "originalStartTimeZone": "originalStartTimeZone-value",
; "originalEndTimeZone": "originalEndTimeZone-value",
; "responseStatus": {
; "response": "",
; "time": "datetime-value"
; },
; "iCalUId": "iCalUId-value",
; "reminderMinutesBeforeStart": 99,
; "isReminderOn": true
; }
; ]
; }
Local $sOriginalStartTimeZone
Local $sOriginalEndTimeZone
Local $sResponseStatusResponse
Local $sResponseStatusTime
Local $sICalUId
Local $iReminderMinutesBeforeStart
Local $bIsReminderOn
Local $i = 0
Local $iCount_i = $oJson.SizeOfArray("value")
While $i < $iCount_i
$oJson.I = $i
$sOriginalStartTimeZone = $oJson.StringOf("value[i].originalStartTimeZone")
$sOriginalEndTimeZone = $oJson.StringOf("value[i].originalEndTimeZone")
$sResponseStatusResponse = $oJson.StringOf("value[i].responseStatus.response")
$sResponseStatusTime = $oJson.StringOf("value[i].responseStatus.time")
$sICalUId = $oJson.StringOf("value[i].iCalUId")
$iReminderMinutesBeforeStart = $oJson.IntOf("value[i].reminderMinutesBeforeStart")
$bIsReminderOn = $oJson.BoolOf("value[i].isReminderOn")
$i = $i + 1
Wend