如何获取最后一个网址

时间:2015-10-14 17:53:15

标签: php curl cookies

$cookiefile = 'cookie.txt';
$params = 'page=http%3A%2F%2Fstackoverflow.com%2F&x=50&y=40';
$url='https://kproxy.com/doproxy.jsp';

$ch = curl_init();  
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch,CURLOPT_HEADER, 0); 
curl_setopt($ch, CURLOPT_POST, count($params));
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0'); 

curl_setopt($ch, CURLOPT_POSTFIELDS, $params);    
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookiefile);
echo curl_exec($ch);
curl_close($ch);

///在执行结束时将我重定向到此网址     ///

https://server4.kproxy.com/servlet/redirect.srv/sruj/sfywreskebutnn/p1/

我想要的是知道如何将url保存在数据库或txt文件中或保存在变量会话中

1 个答案:

答案 0 :(得分:1)

您可以按如下方式获取重定向网址:

$redirectUrl = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);