diff --git a/index.php b/index.php index 00b2786..d81be84 100644 --- a/index.php +++ b/index.php @@ -22,6 +22,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $fileId = extractBoxFileId($boxUrl); $result = null; $error = null; + $debugInfo = []; // Debug information if ($fileId) { // Prepare data for webhook @@ -32,9 +33,11 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { 'timestamp' => date('Y-m-d H:i:s') ]; + $debugInfo['sent_data'] = $data; + // Initialize cURL session $ch = curl_init($webhookUrl); - + // Set cURL options curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); @@ -42,22 +45,28 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Content-Type: application/json' ]); - + // Execute cURL request $response = curl_exec($ch); - + $debugInfo['raw_response'] = $response; + // Check for errors if (curl_errno($ch)) { $error = 'cURL Error: ' . curl_error($ch); + $debugInfo['curl_error'] = curl_error($ch); } else { $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); + $debugInfo['http_code'] = $httpCode; + if ($httpCode >= 200 && $httpCode < 300) { $result = json_decode($response, true); + $debugInfo['decoded_result'] = $result; + $debugInfo['json_decode_error'] = json_last_error_msg(); } else { $error = "HTTP Error: $httpCode - $response"; } } - + // Close cURL session curl_close($ch); } else { @@ -317,6 +326,44 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { + + +