易截截图软件、单文件、免安装、纯绿色、仅160KB

PHP 模拟 Post 的两种方法

function poster()
{
$URL = 'http://www.yw56.com.cn/DIY.asp'; //需要提交到的页面
//下面这段是要提交的数据
$post_data['orderid'] = "YW861736303CN";
$post_data['button'] = "提交";

$referrer="http://www.yw56.com.cn/DIY.asp";
$Cookie="ASPSESSIONIDQASTTQBC=NCCPADLCAKFNICPOABDAFHOP";
$URL_Info=parse_url($URL);
if($referrer=="")
{
$referrer=$_SERVER["SCRIPT_URI"];
}
foreach ($post_data as $key=>$value)
{
$values[]="$key=".urlencode($value);
}

$data_string=implode("&",$values);//提交的数据格式是 a=1&b=2
// Find out which port is needed - if not given use standard (=80)
if (!isset($URL_Info["port"])) {
$URL_Info["port"]=80;
// building POST-request:
//一般做网站用form提交数据后,之后的操作就不用我们不管了,
//这里就是在模拟POST操作的HTTP头,具体的可以去查HTTP协议的资料,并不复杂
$request.="POST ".$URL_Info["path"]." HTTP/1.1\n";
$request.="Host: ".$URL_Info["host"]."\n";
$request.="Referer: $referrer\n";
$request.="Content-type: application/x-www-form-urlencoded\n";
$request.="Content-length: ".strlen($data_string)."\n";
$request.="Connection: close\n";
$request.="\n";
$request.=$data_string."\n";
//exit;
}
//fsockopen的用法就这样子了,不做多说明
$fp = fsockopen($URL_Info["host"], $URL_Info["port"]);
fputs($fp, $request);//把HTTP头发送出去
while(!feof($fp)) {
//$result 是提交后返回的数据
$result .= fgets($fp, 1024);
}
fclose($fp);

echo $result;

}
 
function poster1()
{
$post_data = array();
$post_data['orderid'] = "YW861736303CN";
$post_data['button'] =


相关文档:

怎样才能成为PHP高手?学会"懒惰"的编程

      PHP是一门高效的网络编程语言,由于它具有编写灵活、运行快速等优点,迅速成为Web程序员的首选语言。前不久的一份权威调查表明,现在已经有31.6%的网站使用PHP作为主要的服务器端编程语言。
  但是,要成为一名PHP编程高手却并不容易。并不像很多人想象的那样,只要能够飞快地编写 ......

PHP基本语法


标准代码如下:
<?php
...
?>
短标签模式(此模式需要修改PHP配置,让PHP支持短标签模式):
<?
...
?>
注释:
/* ...*/
//
#

其它:
在php中用";"来分隔语句。
例句:
<?php
echo "Hello World!"
?>
......

——php图像处理类

<?
* +-------------------------------------------------------------+
* | Copyright (c) 2008-2009 Diqiye.Com All rights reserved.
* +-------------------------------------------------------------+
* | Info : 图像处理类
* +------------------------------------------------------------ ......

php之XML转数组函数

<?
/**
* xml2array() will convert the given XML text to an array in the XML structure.
* Link: http://www.bin-co.com/php/scripts/xml2array/
* Arguments : $contents - The XML text
* $get_attributes - 1 or 0. If this is 1 the function will get the attributes as well as the ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号