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
(PureBasic) 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
IncludeFile "CkHttpResponse.pb" IncludeFile "CkHttp.pb" IncludeFile "CkJsonObject.pb" Procedure ChilkatExample() ; This example requires the Chilkat API to have been previously unlocked. ; See Global Unlock Sample for sample code. http.i = CkHttp::ckCreate() If http.i = 0 Debug "Failed to create object." ProcedureReturn EndIf ; Use your previously obtained access token here: Get Outlook Calendar OAuth2 Access Token (Azure AD v2.0 Endpoint). jsonToken.i = CkJsonObject::ckCreate() If jsonToken.i = 0 Debug "Failed to create object." ProcedureReturn EndIf success.i = CkJsonObject::ckLoadFile(jsonToken,"qa_data/tokens/outlookCalendar.json") If success = 0 Debug CkJsonObject::ckLastErrorText(jsonToken) CkHttp::ckDispose(http) CkJsonObject::ckDispose(jsonToken) ProcedureReturn EndIf CkHttp::setCkAuthToken(http, CkJsonObject::ckStringOf(jsonToken,"access_token")) resp.i = CkHttp::ckQuickRequest(http,"GET","https://graph.microsoft.com/v1.0/me/calendars") If CkHttp::ckLastMethodSuccess(http) <> 1 Debug CkHttp::ckLastErrorText(http) CkHttp::ckDispose(http) CkJsonObject::ckDispose(jsonToken) ProcedureReturn EndIf Debug "Response status code = " + Str(CkHttpResponse::ckStatusCode(resp)) ; The HTTP request succeeded if the response status code = 200. If CkHttpResponse::ckStatusCode(resp) <> 200 Debug CkHttpResponse::ckBodyStr(resp) Debug "Failed" CkHttpResponse::ckDispose(resp) CkHttp::ckDispose(http) CkJsonObject::ckDispose(jsonToken) ProcedureReturn EndIf json.i = CkJsonObject::ckCreate() If json.i = 0 Debug "Failed to create object." ProcedureReturn EndIf CkJsonObject::ckLoad(json,CkHttpResponse::ckBodyStr(resp)) CkJsonObject::setCkEmitCompact(json, 0) Debug CkJsonObject::ckEmit(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" ; } ; } ; ] ; } CkHttpResponse::ckDispose(resp) id.s name.s color.s hexColor.s isDefaultCalendar.i changeKey.s canShare.i canViewPrivateItems.i canEdit.i defaultOnlineMeetingProvider.s isTallyingResponses.i isRemovable.i ownerName.s ownerAddress.s j.i count_j.i strVal.s odata_context.s = CkJsonObject::ckStringOf(json,Chr(34) + "@odata.context" + Chr(34)) i.i = 0 count_i.i = CkJsonObject::ckSizeOfArray(json,"value") While i < count_i CkJsonObject::setCkI(json, i) id = CkJsonObject::ckStringOf(json,"value[i].id") name = CkJsonObject::ckStringOf(json,"value[i].name") color = CkJsonObject::ckStringOf(json,"value[i].color") hexColor = CkJsonObject::ckStringOf(json,"value[i].hexColor") isDefaultCalendar = CkJsonObject::ckBoolOf(json,"value[i].isDefaultCalendar") changeKey = CkJsonObject::ckStringOf(json,"value[i].changeKey") canShare = CkJsonObject::ckBoolOf(json,"value[i].canShare") canViewPrivateItems = CkJsonObject::ckBoolOf(json,"value[i].canViewPrivateItems") canEdit = CkJsonObject::ckBoolOf(json,"value[i].canEdit") defaultOnlineMeetingProvider = CkJsonObject::ckStringOf(json,"value[i].defaultOnlineMeetingProvider") isTallyingResponses = CkJsonObject::ckBoolOf(json,"value[i].isTallyingResponses") isRemovable = CkJsonObject::ckBoolOf(json,"value[i].isRemovable") ownerName = CkJsonObject::ckStringOf(json,"value[i].owner.name") ownerAddress = CkJsonObject::ckStringOf(json,"value[i].owner.address") j = 0 count_j = CkJsonObject::ckSizeOfArray(json,"value[i].allowedOnlineMeetingProviders") While j < count_j CkJsonObject::setCkJ(json, j) strVal = CkJsonObject::ckStringOf(json,"value[i].allowedOnlineMeetingProviders[j]") j = j + 1 Wend i = i + 1 Wend CkHttp::ckDispose(http) CkJsonObject::ckDispose(jsonToken) CkJsonObject::ckDispose(json) ProcedureReturn EndProcedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.