在php中模擬POST提交的方法有哪些-創(chuàng)新互聯(lián)

在php中模擬POST提交的方法有哪些?很多新手對(duì)此不是很清楚,為了幫助大家解決這個(gè)難題,下面小編將為大家詳細(xì)講解,有這方面需求的人可以來(lái)學(xué)習(xí)下,希望你能有所收獲。

網(wǎng)站建設(shè)哪家好,找成都創(chuàng)新互聯(lián)!專(zhuān)注于網(wǎng)頁(yè)設(shè)計(jì)、網(wǎng)站建設(shè)、微信開(kāi)發(fā)、重慶小程序開(kāi)發(fā)公司、集團(tuán)企業(yè)網(wǎng)站建設(shè)等服務(wù)項(xiàng)目。為回饋新老客戶(hù)創(chuàng)新互聯(lián)還提供了巴青免費(fèi)建站歡迎大家使用!

php有什么用

php是一個(gè)嵌套的縮寫(xiě)名稱(chēng),是英文超級(jí)文本預(yù)處理語(yǔ)言,它的語(yǔ)法混合了C、Java、Perl以及php自創(chuàng)新的語(yǔ)法,主要用來(lái)做網(wǎng)站開(kāi)發(fā),許多小型網(wǎng)站都用php開(kāi)發(fā),因?yàn)閜hp是開(kāi)源的,從而使得php經(jīng)久不衰。

一、通過(guò)curl函數(shù)


復(fù)制代碼 代碼如下:


$post_data = array();
$post_data['clientname'] = "test08";
$post_data['clientpasswd'] = "test08";
$post_data['submit'] = "submit";
$url='http://xxx.xxx.xxx.xx/xx/xxx/top.php';
$o="";
foreach ($post_data as $k=>$v)
{
    $o.= "$k=".urlencode($v)."&";
}
$post_data=substr($o,0,-1);
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_URL,$url);
//為了支持cookie
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
$result = curl_exec($ch);



二、通過(guò)fsockopen


復(fù)制代碼 代碼如下:


$URL=‘http://xxx.xxx.xxx.xx/xx/xxx/top.php';
$post_data['clientname'] = "test08";
$post_data['clientpasswd'] = "test08";
$post_data['submit'] = "ログイン";
$referrer="";
// parsing the given URL
$URL_Info=parse_url($URL);
// Building referrer
if($referrer=="") // if not given use this script as referrer
$referrer=<PRE class=php name="code">{1}</PRE><BR>
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);
<PRE></PRE>
<P><BR>
&nbsp;</P>
<P>Snoopy 類(lèi)(2)<BR>
sourceforge.net/projects/snoopy/</P>
<P>http://www.redalt.com/xref/trunk/nav.htm?wp-includes/class-snoopy.php.htm</P>
<P>HTTP類(lèi)(1,2)</P>
<P>http://www.phpclasses.org/browse/download/1/file/5/name/http.php</P>
<P>PEAR HTTP_Request</P>
<P>http://pear.php.net/package/HTTP_Request</P>
<P class=akpc_pop>Popularity: 70%</P>
<P>&nbsp;</P>


看完上述內(nèi)容是否對(duì)您有幫助呢?如果還想對(duì)相關(guān)知識(shí)有進(jìn)一步的了解或閱讀更多相關(guān)文章,請(qǐng)關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝您對(duì)創(chuàng)新互聯(lián)網(wǎng)站建設(shè)公司,的支持。

文章名稱(chēng):在php中模擬POST提交的方法有哪些-創(chuàng)新互聯(lián)
網(wǎng)站地址:http://muchs.cn/article40/depdeo.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供標(biāo)簽優(yōu)化、軟件開(kāi)發(fā)、微信小程序、電子商務(wù)動(dòng)態(tài)網(wǎng)站、微信公眾號(hào)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話(huà):028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

網(wǎng)站建設(shè)網(wǎng)站維護(hù)公司