网站建设 郑州网站建设 网站制作 网页设计 网站设计 郑州建网站 - 爱易在线

网站地图 | 网站Tags标签 | RSS订阅 | 加入收藏
您的位置:网站首页 > 博客笔记 > 技术交流 > 正文 技术交流相关信息

php用Curl的post方法只获取header头信息中的Location

作者:郑州网站建设 2013/10/3 17:10:27 点击: 来源:

php用Curl的post方法只获取header头信息中的Location

$posturl="http://www.ie81.com/posturl";   
$postdata="a=1&b=2";           
$ch = curl_init();   
curl_setopt($ch, CURLOPT_POST, 1);   
curl_setopt($ch, CURLOPT_URL,$posturl);   
curl_setopt($ch, CURLOPT_REFERER,"");//REFERER   
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);   
curl_setopt($ch, CURLOPT_HEADER, 1);    
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);     
$content = curl_exec($ch);    
curl_close($ch);   
// 解析HTTP数据流    
list($header, $body) = explode("\r\n\r\n", $content);     
preg_match("/Location:([^\r\n]*)/i", $header, $matches);    
$Location = $matches[1];   
if($Location!=""){   
    echo $Location
}   
else{ echo "未获取到";}

 

分享到:

上一篇:CURL不依赖COOKIEJAR获取COOKIE

下一篇:C#解密虾米的location为真实地址

技术交流推荐阅读

用户评论

最新博文

热门排行

推荐信息

关于爱之易| 付款方式| 联系我们| 网站地图| 网站Tags标签 | RSS订阅