| $ch = Curl_init (); # Set the URL and return the results, whether to return to the head 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 Head curl_setopt ($this->ch, Curlopt_httpheader, Array (' user-agent:mozilla/5.0 ')); # set Post curl_setopt ($ch, Curlopt_post, 1); curl_setopt ($ch, Curlopt_postfields, $poststring); # connection, execution expiration time curl_setopt ($this->ch, Curlopt_connecttimeout, 5); curl_setopt ($this->ch, Curlopt_timeout, 30); # whether to 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 HTTPS curl_setopt ($this->ch, Curlopt_ssl_verifypeer, 0); curl_setopt ($this->ch, curlopt_ssl_verifyhost, 0); # If you need to make a millisecond timeout, you need to add: curl_setopt ($this->ch, curlopt_nosignal, 1); # execution $response = curl_exec ($ch); if (Curl_errno ($ch)) { Curl_error ($ch); Exit (); } Curl_close ($ch); |