From 0dd90996d7981988df6e9038b990c051f67fcab9 Mon Sep 17 00:00:00 2001 From: olinet Date: Sun, 7 Sep 2025 11:04:35 +0200 Subject: [PATCH] AddOn/Calender_Office365_User/OutlookCalendar.php aktualisiert --- .../OutlookCalendar.php | 33 +++++++++++++++++-- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/AddOn/Calender_Office365_User/OutlookCalendar.php b/AddOn/Calender_Office365_User/OutlookCalendar.php index c0661afe..d23d2db4 100644 --- a/AddOn/Calender_Office365_User/OutlookCalendar.php +++ b/AddOn/Calender_Office365_User/OutlookCalendar.php @@ -39,24 +39,51 @@ class OutlookCalendar { } // ------------------------------------------ - // 📅 Termin erstellen + // Termin erstellen public function createEvent($eventData) { $url = "https://graph.microsoft.com/v1.0/me/events"; return $this->sendRequest($url, $eventData, false, 'POST'); } - // ✏️ Termin bearbeiten + // Termin bearbeiten public function updateEvent($eventId, $eventData) { $url = "https://graph.microsoft.com/v1.0/me/events/{$eventId}"; return $this->sendRequest($url, $eventData, false, 'PATCH'); } - // ❌ Termin löschen + // Termin löschen public function deleteEvent($eventId) { $url = "https://graph.microsoft.com/v1.0/me/events/{$eventId}"; return $this->sendRequest($url, [], false, 'DELETE'); } + // Termin laden + public function getEvents($top = 10) { + $url = "https://graph.microsoft.com/v1.0/me/events?\$top=" . intval($top); + $headers = [ + "Authorization: Bearer " . $this->accessToken, + "Accept: application/json" + ]; + + $ch = curl_init($url); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); + $response = curl_exec($ch); + $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); + curl_close($ch); + + if ($httpCode === 200) { + return json_decode($response, true); + } else { + return [ + "error" => true, + "status" => $httpCode, + "message" => $response + ]; + } + } + + // ------------------------------------------ // 🔧 API Request senden (intern) private function sendRequest($url, $data = [], $isForm = false, $method = 'POST') {