php模拟post aspx页面不成功
下面实例返回 是 0|访问限制!请重新加载页面
应该放回 -2|车牌号码错误
/************************************************************************
name: post 测试程序 vesion: 1.0 date: 2004-08-05
*************************************************************************/
$keyimg=$_post['keyimg'];
if($keyimg){
$flag = 0;
//要post的数据
$argv = array(
'action'=>'illagel',
'back4'=>'3248',
'headno'=>'粤',
'no'=>'la9532',
'type'=>'02',
'validate'=>$keyimg
);
//构造要post的字符串
foreach ($argv as $key=>$value) {
if ($flag!=0) {
$params .= &;
$flag = 1;
}
$params.= $key.=;
$params.= urlencode($value);
//$params.= $value;
$flag = 1;
}
echo $params;
$length = strlen($params);
//创建socket连接
$fp = fsockopen(www.gdhzcgs.com,80,$errno,$errstr,10) or exit($errstr.--->.$errno);
//构造post请求的头
//$header = post /illegal.aspx http/1.1\r\n;
$header = post /ajax.aspx http/1.1\r\n;
$header .= host:www.gdhzcgs.com\r\n;
$header .= referer:www.gdhzcgs.com/illegal.aspx\r\n;
$header .= content-type: application/x-www-form-urlencoded\r\n;
$header .= content-length: .$length.\r\n;
$header .= connection: close\r\n\r\n;
//添加post的字符串
$header .= $params.\r\n;
//发送post的数据
fputs($fp,$header);
$inheader = 1;
while (!feof($fp)) {
$line = fgets($fp,1024); //去除请求包的头只显示页面的返回数据
if ($inheader && ($line == \n || $line == \r\n)) {
$inheader = 0;
}
if ($inheader == 0) {
echo $line;
}
}
fclose($fp);
}
else{
echo 'keyimg=空';
}
?>
nbsp;html public -//w3c//dtd xhtml 1.0 transitional//en http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd>
网上车管所
分享到: 更多
------解决方案--------------------
request headers value
(request-line) post /ajax.aspx http/1.1
x-requested-with xmlhttprequest
accept-language zh-cn
referer http://www.gdhzcgs.com/illegal.aspx
accept */*
content-type application/x-www-form-urlencoded
accept-encoding gzip, deflate
user-agent mozilla/5.0 (compatible; msie 9.0; windows nt 6.1; wow64; trident/5.0)
host www.gdhzcgs.com
content-length 69
connection keep-alive
cache-control no-cache
cookie asp.net_sessionid=rimtcb55pc2gcgurkaimgi45; cnzzdata3614737=cnzz_eid=42940778-1343020353-&ntime=1343020353&cnzz_a=0&retime=1343020354714&sin=<ime=1343020354714&rtime=0
有cookie呀..