一、通过curl函数
$post_data = array();<BR>$post_data['clientname'] = "test08";<BR>$post_data['clientpasswd'] = "test08";<BR>$post_data['submit'] = "submit";<BR>$url='http://xxx.xxx.xxx.xx/xx/xxx/top.php';<BR>$o="";<BR>foreach ($post_data as $k=>$v)<BR>{<BR> $o.= "$k=".urlencode($v)."&";<BR>}<BR>$post_data=substr($o,0,-1);<BR>$ch = curl_init();<BR>curl_setopt($ch, CURLOPT_POST, 1);<BR>curl_setopt($ch, CURLOPT_HEADER, 0);<BR>curl_setopt($ch, CURLOPT_URL,$url);<BR>//为了支持cookie<BR>curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');<BR>curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);<BR>$result = curl_exec($ch);<BR>
二、通过fsockopen
$URL=‘http://xxx.xxx.xxx.xx/xx/xxx/top.php';<BR>$post_data['clientname'] = "test08";<BR>$post_data['clientpasswd'] = "test08";<BR>$post_data['submit'] = "ログイン";<BR>$referrer="";<BR>// parsing the given URL<BR>$URL_Info=parse_url($URL);<BR>// Building referrer<BR>if($referrer=="") // if not given use this script as referrer<BR>$referrer=<PRE class="php">{1}
SERVER["SCRIPT_URI"]; // making string from $dataforeach($post_data as $key=>$value)$values[]="$key=".urlencode($value); $data_string=implode("&",$values);// Find out which port is needed - if not given use standard (=80)if(!isset($URL_Info["port"]))$URL_Info["port"]=80;//
building POST-request:$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";$fp = fsockopen($URL_Info["host"],$URL_Info["port"]);fputs($fp, $request);while(!feof($fp)) { $result .= fgets($fp, 128);}fclose($fp);
Snoopy 类(2)
sourceforge.net/p
5本文来源gao!daima.com搞$代!码#网#
搞代gaodaima码
rojects/snoopy/
http://www.redalt.com/xref/trunk/nav.htm?wp-includes/class-snoopy.php.htm
HTTP类(1,2)
http://www.phpclasses.org/browse/download/1/file/5/name/http.php
PEAR HTTP_Request
http://pear.php.net/package/HTTP_Request
Popularity: 70%