AddOn/Calender_Office365_User/OutlookCalendar.php aktualisiert

This commit is contained in:
olinet 2025-09-07 11:04:35 +02:00
parent e1e73d15aa
commit 0dd90996d7
1 changed files with 30 additions and 3 deletions

View File

@ -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') {