1<?PHP2 Header(' Content-type:text/html;charset=utf-8 '); 3 Echo"<pre>"; 4 5 functionCurl$cookie,$user _agent,$destURL,$paramStr= ",$flag= ' Get ',$ip= ' 10.57.22.151 ',$fromurl= ' http://www.baidu.com '){ 6 $curl=Curl_init (); 7 if($flag= = ' Post ') {//Post Delivery8curl_setopt ($curl, curlopt_post, 1); 9curl_setopt ($curl, curlopt_postfields,$paramStr); Ten } onecurl_setopt ($curl, curlopt_url,$destURL);//Address a -curl_setopt ($curl, curlopt_httpheader,Array(' x-forwarded-for: '.$ip, ' Client-ip: '.$ip));//Constructing IP - the -curl_setopt ($curl, curlopt_referer,$fromurl); -curl_setopt ($curl, curlopt_timeout, 10);#10s time-out period - +curl_setopt ($curl, curlopt_useragent,$user _agent); - //curl_setopt ($curl, curlopt_cookiejar, $cookie); +curl_setopt ($curl, curlopt_cookiefile,$cookie); a atcurl_setopt ($curl, curlopt_ssl_verifyhost, 2); -curl_setopt ($curl, curlopt_returntransfer, 1); - $str= Curl_exec ($curl); -Curl_close ($curl); - return $str; - } in - to $postdata= ' a=11111111111 '; + $user _agent= "mozilla/5."Rand(0,100). " (Windows NT 6.1; WOW64; Rv:33.0) gecko/20100101 firefox/33.0 "; - $cookie= ' D:\cookie.txt '; the $getip= ' 66.66. '.Rand(0,16). '. '.Rand(0,158) ; * //file_put_contents (' d:\cookie.txt ', '); $ $cookie _file=dirname(__file__).‘ /cookie.txt '; Panax Notoginseng Ob_start(); - $html= Curl ($cookie _file,$user _agent, ' http://127.0.0.50/b.php ',$postdata, ' Post ',$getip,‘‘); the Ob_end_clean(); + a Echo $html;
Cookie file
1 127.0.0.50 false / false 1418875953 AAAA CCCC
Reprint Address:
http://blog.csdn.net/ebw123/article/details/41980239
Curl sends a request when carrying cookie-reprint not verified