Today docking payment interface, need to get the payment page, found that the payment provider over the link will send 302 jump, and finally found the method, absolute force:
<?PHP$url= ' http://auto.jrj.com.cn/';$ch=curl_init (); curl_setopt ($ch, Curlopt_url,$url); curl_setopt ($ch, Curlopt_header, 0); curl_setopt ($ch, Curlopt_returntransfer, 1);//if the given URL automatically jumps to the new URL, the following parameters can automatically get the new URL content: 302 Jumpcurl_setopt ($ch, Curlopt_followlocation, 1);//sets the maximum number of seconds that curl is allowed to execute. curl_setopt ($ch, Curlopt_timeout, 10); curl_setopt ($ch, Curlopt_useragent, ' mozilla/5.0 (Windows NT 6.1; WOW64; rv:47.0) gecko/20100101 firefox/47.0 '); curl_setopt ($ch, Curlopt_referer,$url); curl_setopt ($ch, curlopt_encoding, ' gzip, deflate ');$content= Curl_exec ($ch);//GET request return code, request successfully returned$code= Curl_getinfo ($ch,curlinfo_http_code);Echo $code. "\ n";//gets the information for a Curl connection resource handle. URL path with jump in $headers$headers= Curl_getinfo ($ch);Var_dump($headers);
Reference Address: http://blog.csdn.net/u013372487/article/details/51954562
PHP Curl Request 302 Jump page