$url, CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 5, CURLOPT_REFERER => 'https://soutenir.index.ngo', CURLOPT_FOLLOWLOCATION => true, CURLOPT_SSL_VERIFYPEER => true, ]); $response = curl_exec($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); if ($response !== false && $httpCode === 200) { $data = json_decode($response, true); if ($data && !isset($data['error'])) { @file_put_contents($cacheFile, $response, LOCK_EX); return $data; } } // Fallback: serve stale cache rather than nothing if (file_exists($cacheFile)) { return json_decode(file_get_contents($cacheFile), true) ?: []; } return []; }