//這是我寫的封裝類,也就是模擬POST提交
你所需要的網(wǎng)站建設服務,我們均能行業(yè)靠前的水平為你提供.標準是產(chǎn)品質量的保證,主要從事成都網(wǎng)站設計、網(wǎng)站制作、企業(yè)網(wǎng)站建設、移動網(wǎng)站建設、網(wǎng)頁設計、品牌網(wǎng)站制作、網(wǎng)頁制作、做網(wǎng)站、建網(wǎng)站。成都創(chuàng)新互聯(lián)擁有實力堅強的技術研發(fā)團隊及素養(yǎng)的視覺設計專才。
//$durl也就是URL地址,比如
//$timeout超時時間
//$data?為POST數(shù)組
//模擬POST提交的用途,采集數(shù)據(jù),模擬用戶登錄(為什么現(xiàn)在登錄需要驗證碼,不是為了測你智商..
更不是考你的眼力,而防止你模擬登錄..用暴力破解法強行破解密碼)
function?curl_file_post_contents($durl,?$timeout?=?5,?$data)?{
$ch?=?curl_init();
curl_setopt($ch,?CURLOPT_URL,?$durl);
curl_setopt($ch,?CURLOPT_RETURNTRANSFER,?1);
curl_setopt($ch,?CURLOPT_TIMEOUT,?$timeout);
curl_setopt($ch,?CURLOPT_USERAGENT,?_USERAGENT_);
curl_setopt($ch,?CURLOPT_REFERER,?_REFERER_);
curl_setopt($ch,?CURLOPT_POST,?1);?//設置為POST傳輸
curl_setopt($ch,?CURLOPT_POSTFIELDS,?$data);?//添加post數(shù)據(jù)
$r?=?curl_exec($ch);
var_dump($ch);
if?($r?===?false)?{??//判斷錯誤
echo?curl_error($ch);
}
$info?=?curl_getinfo($ch);??//能夠在cURL執(zhí)行后獲取這一請求的有關信息
curl_close($ch);
return?$r;
}
本文實例講述了php實現(xiàn)模擬post請求的方法。分享給大家供大家參考。具體如下:
class
Request{
public
static
function
post($url,
$post_data
=
'',
$timeout
=
5){//curl
$ch
=
curl_init();
curl_setopt
($ch,
CURLOPT_URL,
$url);
curl_setopt
($ch,
CURLOPT_POST,
1);
if($post_data
!=
''){
curl_setopt($ch,
CURLOPT_POSTFIELDS,
$post_data);
}
curl_setopt
($ch,
CURLOPT_RETURNTRANSFER,
1);
curl_setopt
($ch,
CURLOPT_CONNECTTIMEOUT,
$timeout);
curl_setopt($ch,
CURLOPT_HEADER,
false);
$file_contents
=
curl_exec($ch);
curl_close($ch);
return
$file_contents;
}
public
static
function
post2($url,
$data=array()){//file_get_content
$postdata
=
http_build_query(
$data
);
$opts
=
array('http'
=
array(
'method'
=
'POST',
'header'
=
'Content-type:
application/x-www-form-urlencoded',
'content'
=
$postdata
)
);
$context
=
stream_context_create($opts);
$result
=
file_get_contents($url,
false,
$context);
return
$result;
}
public
static
function
post3($host,$path,$query,$others=''){//fsocket
$post="POST
$path
HTTP/1.1\r\nHost:
$host\r\n";
$post.="Content-type:
application/x-www-form-";
$post.="urlencoded\r\n${others}";
$post.="User-Agent:
Mozilla
4.0\r\nContent-length:
";
$post.=strlen($query)."\r\nConnection:
close\r\n\r\n$query";
$h=fsockopen($host,80);
fwrite($h,$post);
for($a=0,$r='';!$a;){
$b=fread($h,8192);
$r.=$b;
$a=(($b=='')?1:0);
}
fclose($h);
return
$r;
}
}
$url='http://******/con/Inter.php';
$data=Request::post($url,array('api'='tag_list'));
$data2=Request::post2($url,array('api'='tag_list'));
echo
$data;
希望本文所述對大家的php程序設計有所幫助。
這個問題我沒見過,很感興趣
類似的問題我見過一些。您是不是還上傳了什么東西,然后請你把上傳上限復原,如果就是兩個字符串的話不用那么大。如果提示你大小出現(xiàn)問題就是別的問題了
修改配置的話,記得重啟Apache
然后我的解決方法就是,把代碼刪除,重打一遍
只是傳兩個字符串我不信不好使
還有一個很惡心的問題,緩存
如果再不行就去重新建一個文件測試下。