Answer the question
In order to leave comments, you need to log in
Why is CURL not returning page content?
Good afternoon. CURL l2oops.com
returns an nginx 307 response (redirect), while in the browser the response (just open the page) contains the site page.
Changing the headers doesn't work.
Why is that?
Answer the question
In order to leave comments, you need to log in
Here is a version of the working code:
$url = "http://l2oops.com/";
$uagent = "Opera/9.80 (Windows NT 6.1; WOW64) Presto/2.12.388 Version/12.14";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_ENCODING, "");
curl_setopt($ch, CURLOPT_USERAGENT, $uagent);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 120);
curl_setopt($ch, CURLOPT_TIMEOUT, 120);
curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
curl_setopt ($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
$contents = curl_exec( $ch );
$err = curl_errno( $ch );
$errmsg = curl_error( $ch );
$header = curl_getinfo( $ch );
curl_close( $ch );
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question