$ Ch = curl_init (); # Set the url and return the result, whether to return the header Curl_setopt ($ ch, CURLOPT_URL, 'http: // www.baidu.com /'); Curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1 ); Curl_setopt ($ this-> ch, CURLOPT_HEADER, 1 ); # Cookie file settings Curl_setopt ($ this-> ch, CURLOPT_COOKIEJAR, $ cookie_file ); Curl_setopt ($ this-> ch, CURLOPT_COOKIEFILE, $ cookie_file ); # Extra header Curl_setopt ($ this-> ch, CURLOPT_HTTPHEADER, array ('User-Agent: Mozilla/123456 ')); # Set post Curl_setopt ($ ch, CURLOPT_POST, 1 ); Curl_setopt ($ ch, CURLOPT_POSTFIELDS, $ poststring ); # Connection and execution expiration time Curl_setopt ($ this-> ch, CURLOPT_CONNECTTIMEOUT, 5 ); Curl_setopt ($ this-> ch, CURLOPT_TIMEOUT, 30 ); # Follow 301 302 Curl_setopt ($ this-> ch, CURLOPT_FOLLOWLOCATION, 1 ); Curl_setopt ($ this-> ch, CURLOPT_MAXREDIRS, 10 ); # Refer Curl_setopt ($ this-> ch, CURLOPT_REFERER, $ refer ); # Http version and Port reuse settings Curl_setopt ($ this-> ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1 ); Curl_setopt ($ this-> ch, CURLOPT_FORBID_REUSE, 1 ); # Support for https Curl_setopt ($ this-> ch, CURLOPT_SSL_VERIFYPEER, 0 ); Curl_setopt ($ this-> ch, CURLOPT_SSL_VERIFYHOST, 0 ); # If millisecond timeout is required, add: Curl_setopt ($ this-> ch, CURLOPT_NOSIGNAL, 1 ); # Execution $ Response = curl_exec ($ ch ); If (curl_errno ($ ch )){ Curl_error ($ ch ); Exit (); } Curl_close ($ ch ); |