true, CURLOPT_USERAGENT => USER_AGENT, CURLOPT_HTTPHEADER => $extraHeaders, CURLOPT_TIMEOUT => 20, CURLOPT_FOLLOWLOCATION => true, CURLOPT_MAXREDIRS => 3, ]); $body = curl_exec($ch); $errno = curl_errno($ch); $error = curl_error($ch); $status = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); if ($errno !== 0) { throw new RuntimeException("curl error fetching $url: $error"); } if ($status >= 400) { throw new RuntimeException("HTTP $status fetching $url"); } return $body; }