PHP uses Curl to get 302-after-jump address instances

Source: Internet
Author: User
Tags curl vars

This article mainly introduces PHP using curl to get 302 of the address instance after the jump, need friends can refer to the following

Directly on the code:

The code is as follows:

/* Return a 302 address * *

function curl_post_302 ($url, $vars) {

$ch = Curl_init ();

curl_setopt ($ch, Curlopt_returntransfer, 1);

curl_setopt ($ch, Curlopt_url, $url);

curl_setopt ($ch, Curlopt_post, 1);

curl_setopt ($ch, curlopt_followlocation, 1); 302 redirect

curl_setopt ($ch, Curlopt_postfields, $vars);

$data = curl_exec ($ch);

$Headers = Curl_getinfo ($ch);

Curl_close ($ch);

if ($data!= $Headers)

return $Headers ["url"];

Else

return false;

}

The above curl_post_302 function can be directly taken to the 302 jump address.

Note : Please pay attention to the triple Programming Tutorials section for more wonderful articles .

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.