HttpOperations

🔧 initCurl

Initialize cURL with common options
function initCurl(string $url, string $method, array $headers = []): void { $this->ch = curl_init(); $finalHeaders = array_merge($this->defaultHeaders, $headers); // Ensure we have the username and password if (empty($this->username) || empty($this->password)) { error_log("Warning: Missing authentication credentials for CalDAV request"); } // Set up the cURL options $options = [ CURLOPT_URL => $url, CURLOPT_CUSTOMREQUEST => $method, CURLOPT_RETURNTRANSFER => true, // ... (truncated)

âš™ī¸ Parameters

â†Šī¸ Returns

(void)

🔧 executeRequest

Execute cURL request and handle response
function executeRequest(): array { $response = curl_exec($this->ch); $httpCode = curl_getinfo($this->ch, CURLINFO_HTTP_CODE); $this->lastCurlInfo = curl_getinfo($this->ch); if ($response === false) { $error = curl_error($this->ch); curl_close($this->ch); throw new \Exception("cURL error: " . $error); } curl_close($this->ch); // ... (truncated)

â†Šī¸ Returns

(array)

🔧 sendPutRequest

Send a PUT request
function sendPutRequest(string $url, string $data, array $headers = []): array { $this->initCurl($url, 'PUT', array_merge($headers, [ 'Content-Type: text/calendar; charset=utf-8', 'Content-Length: ' . strlen($data) ])); curl_setopt($this->ch, CURLOPT_POSTFIELDS, $data); return $this->executeRequest(); }

âš™ī¸ Parameters

â†Šī¸ Returns

(array)

🔧 sendDeleteRequest

Send a DELETE request
function sendDeleteRequest(string $url, array $headers = []): array { $this->initCurl($url, 'DELETE', $headers); return $this->executeRequest(); }

âš™ī¸ Parameters

â†Šī¸ Returns

(array)

🔧 buildUrl

Build CalDAV URL
function buildUrl(string $username, string $calendarId, ?string $eventId = null): string { $url = rtrim($this->baseUrl, '/') . '/calendars/' . urlencode($username) . '/' . urlencode($calendarId); if ($eventId) { $url .= '/' . urlencode($eventId) . '.ics'; } return $url; }

âš™ī¸ Parameters

â†Šī¸ Returns

(string)

🔧 setVerbose

Set verbose mode for debugging
function setVerbose(bool $verbose): void { $this->verbose = $verbose; }

âš™ī¸ Parameters

â†Šī¸ Returns

(void)

🔧 setDefaultHeaders

Set default headers for all requests
function setDefaultHeaders(array $headers): void { $this->defaultHeaders = $headers; }

âš™ī¸ Parameters

â†Šī¸ Returns

(void)