R
R
Roman Yakimchuk2016-03-24 15:32:21
PHP
Roman Yakimchuk, 2016-03-24 15:32:21

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

2 answer(s)
N
nikita-slb, 2016-03-24
@yakimchuk-ry

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 );

X
X-, 2016-03-24
NoNAME @XNoNAME

curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
source: stackoverflow.com/questions/3519939/make-curl-foll...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question