Add comprehensive debug output for troubleshooting
- Added debug information section that displays after POST - Shows raw webhook response and HTTP code - Displays decoded result and JSON decode errors - Shows state of $result and $error variables - Helps identify why results aren't displaying 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
f036ad7138
commit
dcd2f96429
1 changed files with 51 additions and 4 deletions
55
index.php
55
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') {
|
|||
</form>
|
||||
</div> <!-- end protected-content -->
|
||||
|
||||
<!-- DEBUG SECTION - Always show after POST -->
|
||||
<?php if ($_SERVER['REQUEST_METHOD'] === 'POST'): ?>
|
||||
<div class="result" style="background-color: #fff3cd; border: 2px solid #ffc107; padding: 15px; margin-top: 20px;">
|
||||
<h2>🔍 DEBUG INFORMATION</h2>
|
||||
|
||||
<div style="margin-bottom: 15px;">
|
||||
<strong>POST Request Received:</strong> Yes<br>
|
||||
<strong>Box URL:</strong> <?php echo htmlspecialchars($boxUrl ?? 'Not set'); ?><br>
|
||||
<strong>Username:</strong> <?php echo htmlspecialchars($username ?? 'Not set'); ?><br>
|
||||
<strong>File ID:</strong> <?php echo htmlspecialchars($fileId ?? 'Not extracted'); ?><br>
|
||||
</div>
|
||||
|
||||
<?php if (!empty($debugInfo)): ?>
|
||||
<div style="background: white; padding: 10px; border-radius: 4px; margin-bottom: 10px;">
|
||||
<h3>Debug Info:</h3>
|
||||
<pre style="max-height: 300px; overflow: auto;"><?php echo htmlspecialchars(print_r($debugInfo, true)); ?></pre>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div style="background: white; padding: 10px; border-radius: 4px; margin-bottom: 10px;">
|
||||
<h3>$result variable:</h3>
|
||||
<strong>isset($result):</strong> <?php echo isset($result) ? 'TRUE' : 'FALSE'; ?><br>
|
||||
<strong>is_null($result):</strong> <?php echo is_null($result) ? 'TRUE' : 'FALSE'; ?><br>
|
||||
<strong>Type:</strong> <?php echo gettype($result); ?><br>
|
||||
<?php if ($result): ?>
|
||||
<pre style="max-height: 300px; overflow: auto;"><?php echo htmlspecialchars(print_r($result, true)); ?></pre>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div style="background: white; padding: 10px; border-radius: 4px;">
|
||||
<h3>$error variable:</h3>
|
||||
<strong>isset($error):</strong> <?php echo isset($error) ? 'TRUE' : 'FALSE'; ?><br>
|
||||
<strong>Value:</strong> <?php echo htmlspecialchars($error ?? 'NULL'); ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<!-- END DEBUG SECTION -->
|
||||
|
||||
<?php if (isset($result) || isset($error)): ?>
|
||||
<div class="result">
|
||||
<h2>Result</h2>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue