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
(Unicode C++) 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
#include <CkHttpW.h> #include <CkJsonObjectW.h> #include <CkHttpResponseW.h> void ChilkatSample(void) { // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. CkHttpW http; // Use your previously obtained access token here: Get Outlook Calendar OAuth2 Access Token (Azure AD v2.0 Endpoint). CkJsonObjectW jsonToken; bool success = jsonToken.LoadFile(L"qa_data/tokens/outlookCalendar.json"); if (success == false) { wprintf(L"%s\n",jsonToken.lastErrorText()); return; } http.put_AuthToken(jsonToken.stringOf(L"access_token")); CkHttpResponseW *resp = http.QuickRequest(L"GET",L"https://graph.microsoft.com/v1.0/me/calendars"); if (http.get_LastMethodSuccess() != true) { wprintf(L"%s\n",http.lastErrorText()); return; } wprintf(L"Response status code = %d\n",resp->get_StatusCode()); // The HTTP request succeeded if the response status code = 200. if (resp->get_StatusCode() != 200) { wprintf(L"%s\n",resp->bodyStr()); wprintf(L"Failed\n"); delete resp; return; } CkJsonObjectW json; json.Load(resp->bodyStr()); json.put_EmitCompact(false); wprintf(L"%s\n",json.emit()); // 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 resp; // Chilkat functions returning "const char *" return a pointer to temporary internal memory owned and managed by Chilkat. // See this example explaining how this memory should be used: const char * functions. const wchar_t *id = 0; const wchar_t *name = 0; const wchar_t *color = 0; const wchar_t *hexColor = 0; bool isDefaultCalendar; const wchar_t *changeKey = 0; bool canShare; bool canViewPrivateItems; bool canEdit; const wchar_t *defaultOnlineMeetingProvider = 0; bool isTallyingResponses; bool isRemovable; const wchar_t *ownerName = 0; const wchar_t *ownerAddress = 0; int j; int count_j; const wchar_t *strVal = 0; const wchar_t *odata_context = json.stringOf(L"\"@odata.context\""); int i = 0; int count_i = json.SizeOfArray(L"value"); while (i < count_i) { json.put_I(i); id = json.stringOf(L"value[i].id"); name = json.stringOf(L"value[i].name"); color = json.stringOf(L"value[i].color"); hexColor = json.stringOf(L"value[i].hexColor"); isDefaultCalendar = json.BoolOf(L"value[i].isDefaultCalendar"); changeKey = json.stringOf(L"value[i].changeKey"); canShare = json.BoolOf(L"value[i].canShare"); canViewPrivateItems = json.BoolOf(L"value[i].canViewPrivateItems"); canEdit = json.BoolOf(L"value[i].canEdit"); defaultOnlineMeetingProvider = json.stringOf(L"value[i].defaultOnlineMeetingProvider"); isTallyingResponses = json.BoolOf(L"value[i].isTallyingResponses"); isRemovable = json.BoolOf(L"value[i].isRemovable"); ownerName = json.stringOf(L"value[i].owner.name"); ownerAddress = json.stringOf(L"value[i].owner.address"); j = 0; count_j = json.SizeOfArray(L"value[i].allowedOnlineMeetingProviders"); while (j < count_j) { json.put_J(j); strVal = json.stringOf(L"value[i].allowedOnlineMeetingProviders[j]"); j = j + 1; } i = i + 1; } } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.