AddOn/Calender_Office365_User/OutlookCalendar.php aktualisiert

This commit is contained in:
olinet 2025-09-07 12:00:35 +02:00
parent 7622838605
commit e408f1e0ca
1 changed files with 27 additions and 2 deletions

View File

@ -16,7 +16,7 @@ class OutlookCalendar {
} }
// ------------------------------------------ // ------------------------------------------
// 🔁 Refresh Token verwenden // Refresh Token verwenden
public function refreshAccessToken() { public function refreshAccessToken() {
$url = "https://login.microsoftonline.com/common/oauth2/v2.0/token"; $url = "https://login.microsoftonline.com/common/oauth2/v2.0/token";
@ -57,7 +57,7 @@ class OutlookCalendar {
return $this->sendRequest($url, [], false, 'DELETE'); return $this->sendRequest($url, [], false, 'DELETE');
} }
// Termin laden // Termine laden
public function getEvents($top = 10) { public function getEvents($top = 10) {
$url = "https://graph.microsoft.com/v1.0/me/events?\$top=" . intval($top); $url = "https://graph.microsoft.com/v1.0/me/events?\$top=" . intval($top);
//return $this->sendRequest($url, $eventData, false, 'GET'); //return $this->sendRequest($url, $eventData, false, 'GET');
@ -83,7 +83,32 @@ class OutlookCalendar {
]; ];
} }
} }
// Einzelnen Termin abrufen
public function getEventById($eventId) {
$url = "https://graph.microsoft.com/v1.0/me/events/" . urlencode($eventId);
$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) // 🔧 API Request senden (intern)