$file); $ch = curl_init($goEndpoint); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload)); curl_setopt($ch, CURLOPT_TIMEOUT, 5); $response = curl_exec($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); if ($httpCode >= 200 && $httpCode < 300) { $result = json_decode($response, true); if (isset($result['page_count']) && is_numeric($result['page_count'])) { $count = (int)$result['page_count']; return $count > 0 ? $count : null; } } return null; } catch (Exception $e) { // If Go service fails, return null gracefully return null; } } } ?>