'error', 'message' => 'KRITISCHER FEHLER: cURL ist nicht aktiviert!']); exit; } $jsonInput = file_get_contents('php://input'); $data = json_decode($jsonInput, true); if ($data) { $wantsRole = $data['discord_role'] ?? false; if ($wantsRole) { $botApiUrl = 'Discord-Bot API Url'; $apiSecretToken = 'TOKEN'; $ch = curl_init($botApiUrl); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonInput); curl_setopt($ch, CURLOPT_TIMEOUT, 10); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Content-Type: application/json', 'Authorization: ' . $apiSecretToken ]); $response = curl_exec($ch); $curl_error = curl_error($ch); $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); if ($curl_error) { header('Content-Type: application/json'); echo json_encode(['status' => 'error', 'message' => 'Verbindungsfehler zum Bot: ' . $curl_error]); exit; } if ($http_code !== 200) { header('Content-Type: application/json'); echo json_encode(['status' => 'error', 'message' => 'Bot meldet HTTP-Code: ' . $http_code, 'bot_response' => $response]); exit; } } header('Content-Type: application/json'); echo json_encode(['status' => 'success', 'message' => 'Verarbeitet.']); } else { http_response_code(400); echo json_encode(['status' => 'error', 'message' => 'Keine gültigen JSON-Daten empfangen.']); } ?>