PHP模拟POST aspx页面不成功,该怎么解决
程序员文章站
2022-05-17 20:26:48
...
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=空';
}
?>
网上车管所
下面实例返回 是 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=空';
}
?>
专题推荐
-
独孤九贱-php全栈开发教程
全栈 170W+
主讲:Peter-Zhu 轻松幽默、简短易学,非常适合PHP学习入门
-
玉女心经-web前端开发教程
入门 80W+
主讲:灭绝师太 由浅入深、明快简洁,非常适合前端学习入门
-
天龙八部-实战开发教程
实战 120W+
主讲:西门大官人 思路清晰、严谨规范,适合有一定web编程基础学习
- 最新文章
- 热门排行
上一篇: 请教这段字符如何转成数组
下一篇: php基础教程
网友评论
文明上网理性发言,请遵守 新闻评论服务协议
我要评论