How to track PHP curl redirection? [duplicate]

0

I use curl to capture data from a page, but it is returning the code 301 (moved). I used CURLOPT_FOLLOWLOCATION , but it's still the same. Does anyone know how to track the redirect?

    
asked by anonymous 06.09.2016 / 15:02

2 answers

0

Normally such a configuration is enough

// Inicia o cURL
$ch = curl_init();

curl_setopt($ch, CURLOPT_TIMEOUT, 5); // tempo em segundos
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); // em segundos
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); // true: permite redirecionamento
curl_setopt($ch, CURLOPT_MAXREDIRS, 1); // quantidade limite de redirecionamentos permitidos

//daqui em diante você define e outros parâmetros, etc.

See also: link

    
06.09.2016 / 18:29
-2

I usually do not know if you're already doing this, use the -L option to keep track of the redirect. Otherwise access the address by the browser and after the redirect replace the URL with the new one.

curl -L <URL>
    
06.09.2016 / 16:46