PHP Curl Request 302 Jump page

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.