Colleagues.
I'm developing a system, but it's giving this error in curl. Does anyone know what it can be?
Colleagues.
I'm developing a system, but it's giving this error in curl. Does anyone know what it can be?
You probably need to accept redirects.
Add the CURLOPT_FOLLOWLOCATION
parameter to the Curl:
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
This will enable you to follow the "Location:" header of your request, so Curl will follow the redirection provided by error 301.
You can set the amount of redirects, using CURLOPT_MAXREDIRS
next to Curl, for example:
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_MAXREDIRS, 5);
CURLOPT_MAXREDIRS
has the function of limiting the number of redirects, in this case 5, but can be changed.
You can also use CURLOPT_AUTOREFERER
to update the "Referer:" for the last "Location:" obtained, may be necessary in some cases.