Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(AutoIt) MS Graph Calendar List EventsRetrieve a list of events in a calendar. The list contains single instance meetings and series masters. For more details, see https://docs.microsoft.com/en-us/graph/api/calendar-list-events?view=graph-rest-1.0
; 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 as shown here: ; Get Microsoft Graph OAuth2 Access Token with Calendars.ReadWrite scope. $oJsonToken = ObjCreate("Chilkat.JsonObject") Local $bSuccess = $oJsonToken.LoadFile("qa_data/tokens/msGraphCalendar.json") If ($bSuccess = False) Then ConsoleWrite($oJsonToken.LastErrorText & @CRLF) Exit EndIf $oHttp.AuthToken = $oJsonToken.StringOf("access_token") ; Specify the calendar id $oHttp.SetUrlVar("id","AQMkADAwATM0MDAAMS1iNTcwLWI2NTEtMDACLTAwCgBGAAADsVyfxjDU406Ic4X7ill8xAcA5_vF7TKKdE6bGCRqXyl2PQAAAgEGAAAA5_vF7TKKdE6bGCRqXyl2PQAClEpRTgAAAA==") ; Send a GET request to https://graph.microsoft.com/v1.0/me/calendars/{$id}/events Local $strResponse = $oHttp.QuickGetStr("https://graph.microsoft.com/v1.0/me/calendars/{$id}/events") If ($oHttp.LastMethodSuccess = False) Then ConsoleWrite($oHttp.LastErrorText & @CRLF) Exit EndIf $oJson = ObjCreate("Chilkat.JsonObject") $oJson.Load($strResponse) $oJson.EmitCompact = False If ($oHttp.LastStatus <> 200) Then ConsoleWrite($oJson.Emit() & @CRLF) ConsoleWrite("Failed, response status code = " & $oHttp.LastStatus & @CRLF) Exit EndIf ConsoleWrite($oJson.Emit() & @CRLF) ; Sample output: ; (See parsing code below..) ; { ; "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('admin%40chilkat.io')/calendars('AQMkADAwATM0MDAAMS1i ... AClEpRTgAAAA%3D%3D')/events", ; "value": [ ; { ; "@odata.etag": "W/\"5+vF7TKKdE6bGCRqXyl2PQAClIgmmw==\"", ; "id": "AQMkADAwATM0MDAAM ... AApRZ7JkAAAA=", ; "createdDateTime": "2019-04-26T14:31:39.8791929Z", ; "lastModifiedDateTime": "2019-04-26T14:31:41.2753537Z", ; "changeKey": "5+vF7TKKdE6bGCRqXyl2PQAClIgmmw==", ; "categories": [ ; ], ; "originalStartTimeZone": "Pacific Standard Time", ; "originalEndTimeZone": "Pacific Standard Time", ; "iCalUId": "040000008200E ... A230FEBFE5F7486A", ; "reminderMinutesBeforeStart": 15, ; "isReminderOn": true, ; "hasAttachments": false, ; "subject": "Let's go for lunch", ; "bodyPreview": "Does mid month work for you?", ; "importance": "normal", ; "sensitivity": "normal", ; "isAllDay": false, ; "isCancelled": false, ; "isOrganizer": true, ; "responseRequested": true, ; "seriesMasterId": null, ; "showAs": "busy", ; "type": "singleInstance", ; "webLink": "https://outlook.live.com/owa/?itemid=AQMkADAwATM0MDAAMS1iNTcwLWI2NT ... gkal8pdj0AApRZ7JkAAAA%3D&exvsurl=1&path=/calendar/item", ; "onlineMeetingUrl": null, ; "recurrence": null, ; "responseStatus": { ; "response": "organizer", ; "time": "0001-01-01T00:00:00Z" ; }, ; "body": { ; "contentType": "html", ; "content": "<html>\r\n<head>\r\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\r\n<meta content=\"text/html; charset=us-ascii\">\r\n</head>\r\n<body>\r\nDoes mid month work for you?\r\n</body>\r\n</html>\r\n" ; }, ; "start": { ; "dateTime": "2019-11-15T20:00:00.0000000", ; "timeZone": "UTC" ; }, ; "end": { ; "dateTime": "2019-11-15T22:00:00.0000000", ; "timeZone": "UTC" ; }, ; "location": { ; "displayName": "Harry's Bar", ; "locationType": "default", ; "uniqueId": "Harry's Bar", ; "uniqueIdType": "private" ; }, ; "locations": [ ; { ; "displayName": "Harry's Bar", ; "locationType": "default", ; "uniqueId": "Harry's Bar", ; "uniqueIdType": "private" ; } ; ], ; "attendees": [ ; { ; "type": "required", ; "status": { ; "response": "none", ; "time": "0001-01-01T00:00:00Z" ; }, ; "emailAddress": { ; "name": "Adele Vance", ; "address": "adelev@contoso.onmicrosoft.com" ; } ; } ; ], ; "organizer": { ; "emailAddress": { ; "name": "Matt", ; "address": "outlook_3A33FCEB9B74CC15@outlook.com" ; } ; } ; } ; ] ; } ; Use this online tool to generate parsing code from sample JSON: ; Generate Parsing Code from JSON Local $sOdataContext Local $i Local $iCount_i Local $sOdataEtag Local $sId Local $sCreatedDateTime Local $sLastModifiedDateTime Local $sChangeKey Local $sOriginalStartTimeZone Local $sOriginalEndTimeZone Local $sICalUId Local $iReminderMinutesBeforeStart Local $bIsReminderOn Local $bHasAttachments Local $subject Local $sBodyPreview Local $sImportance Local $sensitivity Local $bIsAllDay Local $bIsCancelled Local $bIsOrganizer Local $bResponseRequested Local $seriesMasterId Local $showAs Local $sV_type Local $sWebLink Local $sOnlineMeetingUrl Local $sRecurrence Local $sResponseStatusResponse Local $sResponseStatusTime Local $sBodyContentType Local $sBodyContent Local $startDateTime Local $startTimeZone Local $sEndDateTime Local $sEndTimeZone Local $sLocationDisplayName Local $sLocationLocationType Local $sLocationUniqueId Local $sLocationUniqueIdType Local $sOrganizerEmailAddressName Local $sOrganizerEmailAddressAddress Local $iJ Local $iCount_j Local $sDisplayName Local $sLocationType Local $sUniqueId Local $sUniqueIdType Local $statusResponse Local $statusTime Local $sEmailAddressName Local $sEmailAddressAddress $sOdataContext = $oJson.StringOf("""@odata.context""") $i = 0 $iCount_i = $oJson.SizeOfArray("value") While $i < $iCount_i $oJson.I = $i $sOdataEtag = $oJson.StringOf("value[i].""@odata.etag""") $sId = $oJson.StringOf("value[i].id") $sCreatedDateTime = $oJson.StringOf("value[i].createdDateTime") $sLastModifiedDateTime = $oJson.StringOf("value[i].lastModifiedDateTime") $sChangeKey = $oJson.StringOf("value[i].changeKey") $sOriginalStartTimeZone = $oJson.StringOf("value[i].originalStartTimeZone") $sOriginalEndTimeZone = $oJson.StringOf("value[i].originalEndTimeZone") $sICalUId = $oJson.StringOf("value[i].iCalUId") $iReminderMinutesBeforeStart = $oJson.IntOf("value[i].reminderMinutesBeforeStart") $bIsReminderOn = $oJson.BoolOf("value[i].isReminderOn") $bHasAttachments = $oJson.BoolOf("value[i].hasAttachments") $subject = $oJson.StringOf("value[i].subject") $sBodyPreview = $oJson.StringOf("value[i].bodyPreview") $sImportance = $oJson.StringOf("value[i].importance") $sensitivity = $oJson.StringOf("value[i].sensitivity") $bIsAllDay = $oJson.BoolOf("value[i].isAllDay") $bIsCancelled = $oJson.BoolOf("value[i].isCancelled") $bIsOrganizer = $oJson.BoolOf("value[i].isOrganizer") $bResponseRequested = $oJson.BoolOf("value[i].responseRequested") $seriesMasterId = $oJson.StringOf("value[i].seriesMasterId") $showAs = $oJson.StringOf("value[i].showAs") $sV_type = $oJson.StringOf("value[i].type") $sWebLink = $oJson.StringOf("value[i].webLink") $sOnlineMeetingUrl = $oJson.StringOf("value[i].onlineMeetingUrl") $sRecurrence = $oJson.StringOf("value[i].recurrence") $sResponseStatusResponse = $oJson.StringOf("value[i].responseStatus.response") $sResponseStatusTime = $oJson.StringOf("value[i].responseStatus.time") $sBodyContentType = $oJson.StringOf("value[i].body.contentType") $sBodyContent = $oJson.StringOf("value[i].body.content") $startDateTime = $oJson.StringOf("value[i].start.dateTime") $startTimeZone = $oJson.StringOf("value[i].start.timeZone") $sEndDateTime = $oJson.StringOf("value[i].end.dateTime") $sEndTimeZone = $oJson.StringOf("value[i].end.timeZone") $sLocationDisplayName = $oJson.StringOf("value[i].location.displayName") $sLocationLocationType = $oJson.StringOf("value[i].location.locationType") $sLocationUniqueId = $oJson.StringOf("value[i].location.uniqueId") $sLocationUniqueIdType = $oJson.StringOf("value[i].location.uniqueIdType") $sOrganizerEmailAddressName = $oJson.StringOf("value[i].organizer.emailAddress.name") $sOrganizerEmailAddressAddress = $oJson.StringOf("value[i].organizer.emailAddress.address") $iJ = 0 $iCount_j = $oJson.SizeOfArray("value[i].categories") While $iJ < $iCount_j $oJson.J = $iJ ; ... $iJ = $iJ + 1 Wend $iJ = 0 $iCount_j = $oJson.SizeOfArray("value[i].locations") While $iJ < $iCount_j $oJson.J = $iJ $sDisplayName = $oJson.StringOf("value[i].locations[j].displayName") $sLocationType = $oJson.StringOf("value[i].locations[j].locationType") $sUniqueId = $oJson.StringOf("value[i].locations[j].uniqueId") $sUniqueIdType = $oJson.StringOf("value[i].locations[j].uniqueIdType") $iJ = $iJ + 1 Wend $iJ = 0 $iCount_j = $oJson.SizeOfArray("value[i].attendees") While $iJ < $iCount_j $oJson.J = $iJ $sV_type = $oJson.StringOf("value[i].attendees[j].type") $statusResponse = $oJson.StringOf("value[i].attendees[j].status.response") $statusTime = $oJson.StringOf("value[i].attendees[j].status.time") $sEmailAddressName = $oJson.StringOf("value[i].attendees[j].emailAddress.name") $sEmailAddressAddress = $oJson.StringOf("value[i].attendees[j].emailAddress.address") $iJ = $iJ + 1 Wend $i = $i + 1 Wend ConsoleWrite("Success." & @CRLF) |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.