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
(Tcl) 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
load ./chilkat.dll # This example requires the Chilkat API to have been previously unlocked. # See Global Unlock Sample for sample code. set http [new_CkHttp] # Use your previously obtained access token as shown here: # Get Microsoft Graph OAuth2 Access Token with Calendars.ReadWrite scope. set jsonToken [new_CkJsonObject] set success [CkJsonObject_LoadFile $jsonToken "qa_data/tokens/msGraphCalendar.json"] if {$success == 0} then { puts [CkJsonObject_lastErrorText $jsonToken] delete_CkHttp $http delete_CkJsonObject $jsonToken exit } CkHttp_put_AuthToken $http [CkJsonObject_stringOf $jsonToken "access_token"] # Specify the calendar id CkHttp_SetUrlVar $http "id" "AQMkADAwATM0MDAAMS1iNTcwLWI2NTEtMDACLTAwCgBGAAADsVyfxjDU406Ic4X7ill8xAcA5_vF7TKKdE6bGCRqXyl2PQAAAgEGAAAA5_vF7TKKdE6bGCRqXyl2PQAClEpRTgAAAA==" # Send a GET request to https://graph.microsoft.com/v1.0/me/calendars/{$id}/events set strResponse [CkHttp_quickGetStr $http "https://graph.microsoft.com/v1.0/me/calendars/{$id}/events"] if {[CkHttp_get_LastMethodSuccess $http] == 0} then { puts [CkHttp_lastErrorText $http] delete_CkHttp $http delete_CkJsonObject $jsonToken exit } set json [new_CkJsonObject] CkJsonObject_Load $json $strResponse CkJsonObject_put_EmitCompact $json 0 if {[CkHttp_get_LastStatus $http] != 200} then { puts [CkJsonObject_emit $json] puts "Failed, response status code = [CkHttp_get_LastStatus $http]" delete_CkHttp $http delete_CkJsonObject $jsonToken delete_CkJsonObject $json exit } puts [CkJsonObject_emit $json] # 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 set odataContext [CkJsonObject_stringOf $json "\"@odata.context\""] set i 0 set count_i [CkJsonObject_SizeOfArray $json "value"] while {$i < $count_i} { CkJsonObject_put_I $json $i set odataEtag [CkJsonObject_stringOf $json "value[i].\"@odata.etag\""] set id [CkJsonObject_stringOf $json "value[i].id"] set createdDateTime [CkJsonObject_stringOf $json "value[i].createdDateTime"] set lastModifiedDateTime [CkJsonObject_stringOf $json "value[i].lastModifiedDateTime"] set changeKey [CkJsonObject_stringOf $json "value[i].changeKey"] set originalStartTimeZone [CkJsonObject_stringOf $json "value[i].originalStartTimeZone"] set originalEndTimeZone [CkJsonObject_stringOf $json "value[i].originalEndTimeZone"] set iCalUId [CkJsonObject_stringOf $json "value[i].iCalUId"] set reminderMinutesBeforeStart [CkJsonObject_IntOf $json "value[i].reminderMinutesBeforeStart"] set isReminderOn [CkJsonObject_BoolOf $json "value[i].isReminderOn"] set hasAttachments [CkJsonObject_BoolOf $json "value[i].hasAttachments"] set subject [CkJsonObject_stringOf $json "value[i].subject"] set bodyPreview [CkJsonObject_stringOf $json "value[i].bodyPreview"] set importance [CkJsonObject_stringOf $json "value[i].importance"] set sensitivity [CkJsonObject_stringOf $json "value[i].sensitivity"] set isAllDay [CkJsonObject_BoolOf $json "value[i].isAllDay"] set isCancelled [CkJsonObject_BoolOf $json "value[i].isCancelled"] set isOrganizer [CkJsonObject_BoolOf $json "value[i].isOrganizer"] set responseRequested [CkJsonObject_BoolOf $json "value[i].responseRequested"] set seriesMasterId [CkJsonObject_stringOf $json "value[i].seriesMasterId"] set showAs [CkJsonObject_stringOf $json "value[i].showAs"] set v_type [CkJsonObject_stringOf $json "value[i].type"] set webLink [CkJsonObject_stringOf $json "value[i].webLink"] set onlineMeetingUrl [CkJsonObject_stringOf $json "value[i].onlineMeetingUrl"] set recurrence [CkJsonObject_stringOf $json "value[i].recurrence"] set responseStatusResponse [CkJsonObject_stringOf $json "value[i].responseStatus.response"] set responseStatusTime [CkJsonObject_stringOf $json "value[i].responseStatus.time"] set bodyContentType [CkJsonObject_stringOf $json "value[i].body.contentType"] set bodyContent [CkJsonObject_stringOf $json "value[i].body.content"] set startDateTime [CkJsonObject_stringOf $json "value[i].start.dateTime"] set startTimeZone [CkJsonObject_stringOf $json "value[i].start.timeZone"] set endDateTime [CkJsonObject_stringOf $json "value[i].end.dateTime"] set endTimeZone [CkJsonObject_stringOf $json "value[i].end.timeZone"] set locationDisplayName [CkJsonObject_stringOf $json "value[i].location.displayName"] set locationLocationType [CkJsonObject_stringOf $json "value[i].location.locationType"] set locationUniqueId [CkJsonObject_stringOf $json "value[i].location.uniqueId"] set locationUniqueIdType [CkJsonObject_stringOf $json "value[i].location.uniqueIdType"] set organizerEmailAddressName [CkJsonObject_stringOf $json "value[i].organizer.emailAddress.name"] set organizerEmailAddressAddress [CkJsonObject_stringOf $json "value[i].organizer.emailAddress.address"] set j 0 set count_j [CkJsonObject_SizeOfArray $json "value[i].categories"] while {$j < $count_j} { CkJsonObject_put_J $json $j # ... set j [expr $j + 1] } set j 0 set count_j [CkJsonObject_SizeOfArray $json "value[i].locations"] while {$j < $count_j} { CkJsonObject_put_J $json $j set displayName [CkJsonObject_stringOf $json "value[i].locations[j].displayName"] set locationType [CkJsonObject_stringOf $json "value[i].locations[j].locationType"] set uniqueId [CkJsonObject_stringOf $json "value[i].locations[j].uniqueId"] set uniqueIdType [CkJsonObject_stringOf $json "value[i].locations[j].uniqueIdType"] set j [expr $j + 1] } set j 0 set count_j [CkJsonObject_SizeOfArray $json "value[i].attendees"] while {$j < $count_j} { CkJsonObject_put_J $json $j set v_type [CkJsonObject_stringOf $json "value[i].attendees[j].type"] set statusResponse [CkJsonObject_stringOf $json "value[i].attendees[j].status.response"] set statusTime [CkJsonObject_stringOf $json "value[i].attendees[j].status.time"] set emailAddressName [CkJsonObject_stringOf $json "value[i].attendees[j].emailAddress.name"] set emailAddressAddress [CkJsonObject_stringOf $json "value[i].attendees[j].emailAddress.address"] set j [expr $j + 1] } set i [expr $i + 1] } puts "Success." delete_CkHttp $http delete_CkJsonObject $jsonToken delete_CkJsonObject $json |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.