This code works fine for the majority of webpages, but I have started receiving the follow output error for certain web pages.
Unexpected HTTP code: 413
payload too large
I have included a webpage that produces the error in the code variable below.
I have increased the following PHP variables to their max with no luck: post_max_size, upload_max_filesize. I have also tweaked the apache variable LimitRequestBody to the max value also.
Any suggestions would be greatly appreciated.
function get_data($url)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; rv:19.0) Gecko/20100101 Firefox/19.0");
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
$data = curl_exec($ch);
if (!curl_errno($ch))
{
switch ($http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE))
{
case 200: # OK
break;
default:
echo 'Unexpected HTTP code: ', $http_code, "\n";
}
}
curl_close($ch);
return $data;
}
$url = "https://www.oddschecker.com/golf/open-championship/2021-open-championship/winner";
$returned_content = get_data($url);
echo "<Br>".$returned_content;