From 75e262ea266bc2befe902dcf01bc4916e718a37a Mon Sep 17 00:00:00 2001 From: Cedric Date: Thu, 23 Jul 2026 10:27:00 +0200 Subject: [PATCH] Actualiser api.php --- api.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/api.php b/api.php index 9e184db..266a1ec 100644 --- a/api.php +++ b/api.php @@ -69,14 +69,20 @@ function httpGet($url, $timeout = 10, $headers = []) { curl_setopt_array($ch, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => $timeout, - CURLOPT_SSL_VERIFYPEER => false, + CURLOPT_CONNECTTIMEOUT => 5, // Échoue vite si le serveur est injoignable + CURLOPT_FOLLOWLOCATION => true, // Indispensable : suit les redirections 301/302 + CURLOPT_ENCODING => '', // Gère automatiquement la compression (Gzip/Deflate) + CURLOPT_SSL_VERIFYPEER => false, // À passer à true en production CURLOPT_USERAGENT => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0', CURLOPT_HTTPHEADER => $headers ]); + $res = curl_exec($ch); $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); - return ($code === 200) ? $res : null; + + // On accepte le code 200 (OK), mais aussi 201 ou 202 selon les APIs + return ($code >= 200 && $code < 300) ? $res : null; } function removeAccentsForUrl($str) {