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) 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
#include <C_CkHttpW.h> #include <C_CkJsonObjectW.h> void ChilkatSample(void) { HCkHttpW http; HCkJsonObjectW jsonToken; BOOL success; const wchar_t *strResponse; HCkJsonObjectW json; const wchar_t *odataContext; int i; int count_i; const wchar_t *odataEtag; const wchar_t *id; const wchar_t *createdDateTime; const wchar_t *lastModifiedDateTime; const wchar_t *changeKey; const wchar_t *originalStartTimeZone; const wchar_t *originalEndTimeZone; const wchar_t *iCalUId; int reminderMinutesBeforeStart; BOOL isReminderOn; BOOL hasAttachments; const wchar_t *subject; const wchar_t *bodyPreview; const wchar_t *importance; const wchar_t *sensitivity; BOOL isAllDay; BOOL isCancelled; BOOL isOrganizer; BOOL responseRequested; const wchar_t *seriesMasterId; const wchar_t *showAs; const wchar_t *v_type; const wchar_t *webLink; const wchar_t *onlineMeetingUrl; const wchar_t *recurrence; const wchar_t *responseStatusResponse; const wchar_t *responseStatusTime; const wchar_t *bodyContentType; const wchar_t *bodyContent; const wchar_t *startDateTime; const wchar_t *startTimeZone; const wchar_t *endDateTime; const wchar_t *endTimeZone; const wchar_t *locationDisplayName; const wchar_t *locationLocationType; const wchar_t *locationUniqueId; const wchar_t *locationUniqueIdType; const wchar_t *organizerEmailAddressName; const wchar_t *organizerEmailAddressAddress; int j; int count_j; const wchar_t *displayName; const wchar_t *locationType; const wchar_t *uniqueId; const wchar_t *uniqueIdType; const wchar_t *statusResponse; const wchar_t *statusTime; const wchar_t *emailAddressName; const wchar_t *emailAddressAddress; // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. http = CkHttpW_Create(); // Use your previously obtained access token as shown here: // Get Microsoft Graph OAuth2 Access Token with Calendars.ReadWrite scope. jsonToken = CkJsonObjectW_Create(); success = CkJsonObjectW_LoadFile(jsonToken,L"qa_data/tokens/msGraphCalendar.json"); if (success == FALSE) { wprintf(L"%s\n",CkJsonObjectW_lastErrorText(jsonToken)); CkHttpW_Dispose(http); CkJsonObjectW_Dispose(jsonToken); return; } CkHttpW_putAuthToken(http,CkJsonObjectW_stringOf(jsonToken,L"access_token")); // Specify the calendar id CkHttpW_SetUrlVar(http,L"id",L"AQMkADAwATM0MDAAMS1iNTcwLWI2NTEtMDACLTAwCgBGAAADsVyfxjDU406Ic4X7ill8xAcA5_vF7TKKdE6bGCRqXyl2PQAAAgEGAAAA5_vF7TKKdE6bGCRqXyl2PQAClEpRTgAAAA=="); // Send a GET request to https://graph.microsoft.com/v1.0/me/calendars/{$id}/events strResponse = CkHttpW_quickGetStr(http,L"https://graph.microsoft.com/v1.0/me/calendars/{$id}/events"); if (CkHttpW_getLastMethodSuccess(http) == FALSE) { wprintf(L"%s\n",CkHttpW_lastErrorText(http)); CkHttpW_Dispose(http); CkJsonObjectW_Dispose(jsonToken); return; } json = CkJsonObjectW_Create(); CkJsonObjectW_Load(json,strResponse); CkJsonObjectW_putEmitCompact(json,FALSE); if (CkHttpW_getLastStatus(http) != 200) { wprintf(L"%s\n",CkJsonObjectW_emit(json)); wprintf(L"Failed, response status code = %d\n",CkHttpW_getLastStatus(http)); CkHttpW_Dispose(http); CkJsonObjectW_Dispose(jsonToken); CkJsonObjectW_Dispose(json); return; } wprintf(L"%s\n",CkJsonObjectW_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 odataContext = CkJsonObjectW_stringOf(json,L"\"@odata.context\""); i = 0; count_i = CkJsonObjectW_SizeOfArray(json,L"value"); while (i < count_i) { CkJsonObjectW_putI(json,i); odataEtag = CkJsonObjectW_stringOf(json,L"value[i].\"@odata.etag\""); id = CkJsonObjectW_stringOf(json,L"value[i].id"); createdDateTime = CkJsonObjectW_stringOf(json,L"value[i].createdDateTime"); lastModifiedDateTime = CkJsonObjectW_stringOf(json,L"value[i].lastModifiedDateTime"); changeKey = CkJsonObjectW_stringOf(json,L"value[i].changeKey"); originalStartTimeZone = CkJsonObjectW_stringOf(json,L"value[i].originalStartTimeZone"); originalEndTimeZone = CkJsonObjectW_stringOf(json,L"value[i].originalEndTimeZone"); iCalUId = CkJsonObjectW_stringOf(json,L"value[i].iCalUId"); reminderMinutesBeforeStart = CkJsonObjectW_IntOf(json,L"value[i].reminderMinutesBeforeStart"); isReminderOn = CkJsonObjectW_BoolOf(json,L"value[i].isReminderOn"); hasAttachments = CkJsonObjectW_BoolOf(json,L"value[i].hasAttachments"); subject = CkJsonObjectW_stringOf(json,L"value[i].subject"); bodyPreview = CkJsonObjectW_stringOf(json,L"value[i].bodyPreview"); importance = CkJsonObjectW_stringOf(json,L"value[i].importance"); sensitivity = CkJsonObjectW_stringOf(json,L"value[i].sensitivity"); isAllDay = CkJsonObjectW_BoolOf(json,L"value[i].isAllDay"); isCancelled = CkJsonObjectW_BoolOf(json,L"value[i].isCancelled"); isOrganizer = CkJsonObjectW_BoolOf(json,L"value[i].isOrganizer"); responseRequested = CkJsonObjectW_BoolOf(json,L"value[i].responseRequested"); seriesMasterId = CkJsonObjectW_stringOf(json,L"value[i].seriesMasterId"); showAs = CkJsonObjectW_stringOf(json,L"value[i].showAs"); v_type = CkJsonObjectW_stringOf(json,L"value[i].type"); webLink = CkJsonObjectW_stringOf(json,L"value[i].webLink"); onlineMeetingUrl = CkJsonObjectW_stringOf(json,L"value[i].onlineMeetingUrl"); recurrence = CkJsonObjectW_stringOf(json,L"value[i].recurrence"); responseStatusResponse = CkJsonObjectW_stringOf(json,L"value[i].responseStatus.response"); responseStatusTime = CkJsonObjectW_stringOf(json,L"value[i].responseStatus.time"); bodyContentType = CkJsonObjectW_stringOf(json,L"value[i].body.contentType"); bodyContent = CkJsonObjectW_stringOf(json,L"value[i].body.content"); startDateTime = CkJsonObjectW_stringOf(json,L"value[i].start.dateTime"); startTimeZone = CkJsonObjectW_stringOf(json,L"value[i].start.timeZone"); endDateTime = CkJsonObjectW_stringOf(json,L"value[i].end.dateTime"); endTimeZone = CkJsonObjectW_stringOf(json,L"value[i].end.timeZone"); locationDisplayName = CkJsonObjectW_stringOf(json,L"value[i].location.displayName"); locationLocationType = CkJsonObjectW_stringOf(json,L"value[i].location.locationType"); locationUniqueId = CkJsonObjectW_stringOf(json,L"value[i].location.uniqueId"); locationUniqueIdType = CkJsonObjectW_stringOf(json,L"value[i].location.uniqueIdType"); organizerEmailAddressName = CkJsonObjectW_stringOf(json,L"value[i].organizer.emailAddress.name"); organizerEmailAddressAddress = CkJsonObjectW_stringOf(json,L"value[i].organizer.emailAddress.address"); j = 0; count_j = CkJsonObjectW_SizeOfArray(json,L"value[i].categories"); while (j < count_j) { CkJsonObjectW_putJ(json,j); // ... j = j + 1; } j = 0; count_j = CkJsonObjectW_SizeOfArray(json,L"value[i].locations"); while (j < count_j) { CkJsonObjectW_putJ(json,j); displayName = CkJsonObjectW_stringOf(json,L"value[i].locations[j].displayName"); locationType = CkJsonObjectW_stringOf(json,L"value[i].locations[j].locationType"); uniqueId = CkJsonObjectW_stringOf(json,L"value[i].locations[j].uniqueId"); uniqueIdType = CkJsonObjectW_stringOf(json,L"value[i].locations[j].uniqueIdType"); j = j + 1; } j = 0; count_j = CkJsonObjectW_SizeOfArray(json,L"value[i].attendees"); while (j < count_j) { CkJsonObjectW_putJ(json,j); v_type = CkJsonObjectW_stringOf(json,L"value[i].attendees[j].type"); statusResponse = CkJsonObjectW_stringOf(json,L"value[i].attendees[j].status.response"); statusTime = CkJsonObjectW_stringOf(json,L"value[i].attendees[j].status.time"); emailAddressName = CkJsonObjectW_stringOf(json,L"value[i].attendees[j].emailAddress.name"); emailAddressAddress = CkJsonObjectW_stringOf(json,L"value[i].attendees[j].emailAddress.address"); j = j + 1; } i = i + 1; } wprintf(L"Success.\n"); CkHttpW_Dispose(http); CkJsonObjectW_Dispose(jsonToken); CkJsonObjectW_Dispose(json); } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.