有一个网站 登陆之后 经过四部重定向 进入最终主页 第一步是通过post 后三步是通过get
后一步重定向的发送的head中的url是上一步response中的的Location:
第一步是post 所写代码运行 均正常 最终也能得到post之后的location地址 作为第二步的url 但为何 模拟第二步的get 之后 $rs = curl_exec($ch) 打印$rs 出现 HTTP/1.1 500 Internal Server Error
Date: Thu, 19 Apr 2012 10:05:51 GMT
Server: Apache
Last-Modified: Tue, 22 Jul 2008 10:42:13 GMT
Accept-Ranges: bytes
Content-Length: 588
Connection: close
Content-Type: text/html由此得不到第二部的head相关信息
求教各位大大 此错误的可能发生的原因 //第一步的模拟post登录
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch,CURLOPT_FOLLOWLOCATION,1);
$rs = curl_exec($ch);
if ($rs === null) {
echo "cURL Error: " . curl_error($ch);die;
}
$info = explode(" ",$rs);
$info = explode("\n",$info[67]);
curl_close($ch);
//第二步的模拟post重定向后通过get的登录
$url = $info[0];
$cu = curl_init();
curl_setopt($cu, CURLOPT_HEADER, 1);
curl_setopt($cu, CURLOPT_URL, $url);
curl_setopt($cu, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($cu, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($cu,CURLOPT_FOLLOWLOCATION,1);
$rs = curl_exec($cu);
if ($rs === null) {
echo "cURL Error: " . curl_error($ch);die;
}
curl_close($cu);
unset($ch);
后一步重定向的发送的head中的url是上一步response中的的Location:
第一步是post 所写代码运行 均正常 最终也能得到post之后的location地址 作为第二步的url 但为何 模拟第二步的get 之后 $rs = curl_exec($ch) 打印$rs 出现 HTTP/1.1 500 Internal Server Error
Date: Thu, 19 Apr 2012 10:05:51 GMT
Server: Apache
Last-Modified: Tue, 22 Jul 2008 10:42:13 GMT
Accept-Ranges: bytes
Content-Length: 588
Connection: close
Content-Type: text/html由此得不到第二部的head相关信息
求教各位大大 此错误的可能发生的原因 //第一步的模拟post登录
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch,CURLOPT_FOLLOWLOCATION,1);
$rs = curl_exec($ch);
if ($rs === null) {
echo "cURL Error: " . curl_error($ch);die;
}
$info = explode(" ",$rs);
$info = explode("\n",$info[67]);
curl_close($ch);
//第二步的模拟post重定向后通过get的登录
$url = $info[0];
$cu = curl_init();
curl_setopt($cu, CURLOPT_HEADER, 1);
curl_setopt($cu, CURLOPT_URL, $url);
curl_setopt($cu, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($cu, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($cu,CURLOPT_FOLLOWLOCATION,1);
$rs = curl_exec($cu);
if ($rs === null) {
echo "cURL Error: " . curl_error($ch);die;
}
curl_close($cu);
unset($ch);
如果仅仅是get url为什么不用location
如果仅仅是get url为什么不用location" 改成post之后还是同样的错误 而且之前用工具查看 是第一步是post 后面几步都是get的方式 还有用location 关键是location在head里面 第二步得不到head的信息
Connection:close
Content-Length:588
Content-Type:text/html
Date:Fri, 20 Apr 2012 06:17:40 GMT
Last-Modified:Tue, 22 Jul 2008 10:42:13 GMT
Server:Apache
试了一下 Response Headers 里面仍然没有Location
第一个post请求返回的http code是3XX的吗,它不返回location你也没办法啊