Home > Backend Development > PHP Tutorial > PHP uses CURL to obtain the address instance after 302 jump_PHP tutorial

PHP uses CURL to obtain the address instance after 302 jump_PHP tutorial

WBOY
Release: 2016-07-13 10:30:46
Original
1310 people have browsed it

Go directly to the code:

Copy 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 curl_post_302 function above can directly get the 302 jump address.

http://www.bkjia.com/PHPjc/764623.html

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/764623.htmlTechArticleDirectly enter the code: Copy the code as follows: /*Return a 302 address*/ function curl_post_302($url, $ vars) { $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_s...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template