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) Outlook Calendar List CalendarsSee more Outlook Calendar ExamplesGet all the user's calendars. For more information, see https://docs.microsoft.com/en-us/graph/api/user-list-calendars?view=graph-rest-1.0&tabs=http
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 here: Get Outlook Calendar OAuth2 Access Token (Azure AD v2.0 Endpoint). set jsonToken [new_CkJsonObject] set success [CkJsonObject_LoadFile $jsonToken "qa_data/tokens/outlookCalendar.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"] # resp is a CkHttpResponse set resp [CkHttp_QuickRequest $http "GET" "https://graph.microsoft.com/v1.0/me/calendars"] if {[CkHttp_get_LastMethodSuccess $http] != 1} then { puts [CkHttp_lastErrorText $http] delete_CkHttp $http delete_CkJsonObject $jsonToken exit } puts "Response status code = [CkHttpResponse_get_StatusCode $resp]" # The HTTP request succeeded if the response status code = 200. if {[CkHttpResponse_get_StatusCode $resp] != 200} then { puts [CkHttpResponse_bodyStr $resp] puts "Failed" delete_CkHttpResponse $resp delete_CkHttp $http delete_CkJsonObject $jsonToken exit } set json [new_CkJsonObject] CkJsonObject_Load $json [CkHttpResponse_bodyStr $resp] CkJsonObject_put_EmitCompact $json 0 puts [CkJsonObject_emit $json] # Here is a sample response: # Use this online tool to generate parsing code from sample JSON: # Generate Parsing Code from JSON # { # "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#me/calendars", # "value": [ # { # "@odata.id": "https://graph.microsoft.com/v1.0/users('ddfcd489-628b-40d7-b48b-57002df800e5@1717622f-1d94-4d0c-9d74-709fad664b77')/calendars('AAMkAGI2TGuLAAA=')", # "id": "AAMkAGI2TGuLAAA=", # "name": "Calendar", # "color": "auto", # "changeKey": "nfZyf7VcrEKLNoU37KWlkQAAA0x0+w==", # "canShare":true, # "canViewPrivateItems":true, # "hexColor": "", # "canEdit":true, # "allowedOnlineMeetingProviders": [ # "teamsForBusiness" # ], # "defaultOnlineMeetingProvider": "teamsForBusiness", # "isTallyingResponses": true, # "isRemovable": false, # "owner":{ # "name":"Samantha Booth", # "address":"samanthab@adatum.onmicrosoft.com" # } # } # ] # } delete_CkHttpResponse $resp set odata_context [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 id [CkJsonObject_stringOf $json "value[i].id"] set name [CkJsonObject_stringOf $json "value[i].name"] set color [CkJsonObject_stringOf $json "value[i].color"] set hexColor [CkJsonObject_stringOf $json "value[i].hexColor"] set isDefaultCalendar [CkJsonObject_BoolOf $json "value[i].isDefaultCalendar"] set changeKey [CkJsonObject_stringOf $json "value[i].changeKey"] set canShare [CkJsonObject_BoolOf $json "value[i].canShare"] set canViewPrivateItems [CkJsonObject_BoolOf $json "value[i].canViewPrivateItems"] set canEdit [CkJsonObject_BoolOf $json "value[i].canEdit"] set defaultOnlineMeetingProvider [CkJsonObject_stringOf $json "value[i].defaultOnlineMeetingProvider"] set isTallyingResponses [CkJsonObject_BoolOf $json "value[i].isTallyingResponses"] set isRemovable [CkJsonObject_BoolOf $json "value[i].isRemovable"] set ownerName [CkJsonObject_stringOf $json "value[i].owner.name"] set ownerAddress [CkJsonObject_stringOf $json "value[i].owner.address"] set j 0 set count_j [CkJsonObject_SizeOfArray $json "value[i].allowedOnlineMeetingProviders"] while {$j < $count_j} { CkJsonObject_put_J $json $j set strVal [CkJsonObject_stringOf $json "value[i].allowedOnlineMeetingProviders[j]"] set j [expr $j + 1] } set i [expr $i + 1] } delete_CkHttp $http delete_CkJsonObject $jsonToken delete_CkJsonObject $json |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.