LoadFile('qa_data/tokens/msGraphCalendar.json'); if ($success == false) { print $jsonToken->lastErrorText() . "\n"; exit; } $http->put_AuthToken($jsonToken->stringOf('access_token')); $json = new CkJsonObject(); $json->UpdateString('subject','Lets go for lunch'); $json->UpdateString('body.contentType','HTML'); $json->UpdateString('body.content','Does mid month work for you?'); $json->UpdateString('start.dateTime','2019-11-15T12:00:00'); $json->UpdateString('start.timeZone','Pacific Standard Time'); $json->UpdateString('end.dateTime','2019-11-15T14:00:00'); $json->UpdateString('end.timeZone','Pacific Standard Time'); $json->UpdateString('location.displayName','Harrys Bar'); $json->UpdateString('attendees[0].emailAddress.address','adelev@contoso.onmicrosoft.com'); $json->UpdateString('attendees[0].emailAddress.name','Adele Vance'); $json->UpdateString('attendees[0].type','required'); // POST the JSON to https://graph.microsoft.com/v1.0/me/calendars/{id}/events // This is posting to a calendar in the default calendarGroup. // Specify the calendar id $http->SetUrlVar('id','AQMkADAwATM0MDAAMS1iNTcwLWI2NTEtMDACLTAwCgBGAAADsVyfxjDU406Ic4X7ill8xAcA5_vF7TKKdE6bGCRqXyl2PQAAAgEGAAAA5_vF7TKKdE6bGCRqXyl2PQAClEpRTgAAAA=='); // resp is a CkHttpResponse $resp = $http->PostJson3('https://graph.microsoft.com/v1.0/me/calendars/{$id}/events','application/json',$json); if ($http->get_LastMethodSuccess() == false) { print $http->lastErrorText() . "\n"; exit; } $json->Load($resp->bodyStr()); $json->put_EmitCompact(false); if ($resp->get_StatusCode() != 201) { print $json->emit() . "\n"; print 'Failed, response status code = ' . $resp->get_StatusCode() . "\n"; exit; } print $json->emit() . "\n"; // Use this online tool to generate parsing code from sample JSON: // Generate Parsing Code from JSON $odataContext = $json->stringOf('\'@odata.context\''); $odataEtag = $json->stringOf('\'@odata.etag\''); $id = $json->stringOf('id'); $createdDateTime = $json->stringOf('createdDateTime'); $lastModifiedDateTime = $json->stringOf('lastModifiedDateTime'); $changeKey = $json->stringOf('changeKey'); $originalStartTimeZone = $json->stringOf('originalStartTimeZone'); $originalEndTimeZone = $json->stringOf('originalEndTimeZone'); $iCalUId = $json->stringOf('iCalUId'); $reminderMinutesBeforeStart = $json->IntOf('reminderMinutesBeforeStart'); $isReminderOn = $json->BoolOf('isReminderOn'); $hasAttachments = $json->BoolOf('hasAttachments'); $subject = $json->stringOf('subject'); $bodyPreview = $json->stringOf('bodyPreview'); $importance = $json->stringOf('importance'); $sensitivity = $json->stringOf('sensitivity'); $isAllDay = $json->BoolOf('isAllDay'); $isCancelled = $json->BoolOf('isCancelled'); $isOrganizer = $json->BoolOf('isOrganizer'); $responseRequested = $json->BoolOf('responseRequested'); $seriesMasterId = $json->stringOf('seriesMasterId'); $showAs = $json->stringOf('showAs'); $type = $json->stringOf('type'); $webLink = $json->stringOf('webLink'); $onlineMeetingUrl = $json->stringOf('onlineMeetingUrl'); $recurrence = $json->stringOf('recurrence'); $responseStatusResponse = $json->stringOf('responseStatus.response'); $responseStatusTime = $json->stringOf('responseStatus.time'); $bodyContentType = $json->stringOf('body.contentType'); $bodyContent = $json->stringOf('body.content'); $startDateTime = $json->stringOf('start.dateTime'); $startTimeZone = $json->stringOf('start.timeZone'); $endDateTime = $json->stringOf('end.dateTime'); $endTimeZone = $json->stringOf('end.timeZone'); $locationDisplayName = $json->stringOf('location.displayName'); $locationLocationType = $json->stringOf('location.locationType'); $locationUniqueId = $json->stringOf('location.uniqueId'); $locationUniqueIdType = $json->stringOf('location.uniqueIdType'); $organizerEmailAddressName = $json->stringOf('organizer.emailAddress.name'); $organizerEmailAddressAddress = $json->stringOf('organizer.emailAddress.address'); $i = 0; $count_i = $json->SizeOfArray('categories'); while ($i < $count_i) { $json->put_I($i); // ... $i = $i + 1; } $i = 0; $count_i = $json->SizeOfArray('locations'); while ($i < $count_i) { $json->put_I($i); $displayName = $json->stringOf('locations[i].displayName'); $locationType = $json->stringOf('locations[i].locationType'); $uniqueId = $json->stringOf('locations[i].uniqueId'); $uniqueIdType = $json->stringOf('locations[i].uniqueIdType'); $i = $i + 1; } $i = 0; $count_i = $json->SizeOfArray('attendees'); while ($i < $count_i) { $json->put_I($i); $type = $json->stringOf('attendees[i].type'); $statusResponse = $json->stringOf('attendees[i].status.response'); $statusTime = $json->stringOf('attendees[i].status.time'); $emailAddressName = $json->stringOf('attendees[i].emailAddress.name'); $emailAddressAddress = $json->stringOf('attendees[i].emailAddress.address'); $i = $i + 1; } print 'Success.' . "\n"; ?>