AddOn/Calender_Office365_User/OutlookCalendar.php aktualisiert
This commit is contained in:
parent
e1e73d15aa
commit
0dd90996d7
|
|
@ -39,24 +39,51 @@ class OutlookCalendar {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------
|
// ------------------------------------------
|
||||||
// 📅 Termin erstellen
|
// Termin erstellen
|
||||||
public function createEvent($eventData) {
|
public function createEvent($eventData) {
|
||||||
$url = "https://graph.microsoft.com/v1.0/me/events";
|
$url = "https://graph.microsoft.com/v1.0/me/events";
|
||||||
return $this->sendRequest($url, $eventData, false, 'POST');
|
return $this->sendRequest($url, $eventData, false, 'POST');
|
||||||
}
|
}
|
||||||
|
|
||||||
// ✏️ Termin bearbeiten
|
// Termin bearbeiten
|
||||||
public function updateEvent($eventId, $eventData) {
|
public function updateEvent($eventId, $eventData) {
|
||||||
$url = "https://graph.microsoft.com/v1.0/me/events/{$eventId}";
|
$url = "https://graph.microsoft.com/v1.0/me/events/{$eventId}";
|
||||||
return $this->sendRequest($url, $eventData, false, 'PATCH');
|
return $this->sendRequest($url, $eventData, false, 'PATCH');
|
||||||
}
|
}
|
||||||
|
|
||||||
// ❌ Termin löschen
|
// Termin löschen
|
||||||
public function deleteEvent($eventId) {
|
public function deleteEvent($eventId) {
|
||||||
$url = "https://graph.microsoft.com/v1.0/me/events/{$eventId}";
|
$url = "https://graph.microsoft.com/v1.0/me/events/{$eventId}";
|
||||||
return $this->sendRequest($url, [], false, 'DELETE');
|
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)
|
// 🔧 API Request senden (intern)
|
||||||
private function sendRequest($url, $data = [], $isForm = false, $method = 'POST') {
|
private function sendRequest($url, $data = [], $isForm = false, $method = 'POST') {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue