CURL Analog HTTP Commit

Source: Internet
Author: User

1:curl Analog Get Commit

Private functionHttpGet ($url) {   $curl=Curl_init (); curl_setopt ($curl, Curlopt_returntransfer,true); curl_setopt ($curl, Curlopt_timeout, 500); curl_setopt ($curl, Curlopt_ssl_verifypeer,false); curl_setopt ($curl, Curlopt_ssl_verifyhost,false); curl_setopt ($curl, Curlopt_url,$url); $res= Curl_exec ($curl); Curl_close ($curl); return $res;}

2:curl Analog Post Submission

//Analog Post SubmissionfunctionHttp_request ($url,$data,$method= "POST"){$ch= Curl_init ();//Initializecurl_setopt ($ch, Curlopt_url,$url);//Request Addresscurl_setopt ($ch, Curlopt_customrequest,$method);//Request Methodcurl_setopt ($ch, Curlopt_ssl_verifypeer,FALSE); curl_setopt ($ch, Curlopt_ssl_verifyhost,FALSE); curl_setopt ($ch, Curlopt_useragent, ' mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0) '); curl_setopt ($ch, Curlopt_followlocation, 1); curl_setopt ($ch, Curlopt_autoreferer, 1);if($method= = ' POST '){//Post mode to add datacurl_setopt ($ch, Curlopt_postfields,$data);} curl_setopt ($ch, Curlopt_returntransfer,TRUE);$tmpinfo= Curl_exec ($ch);//Executionif(Curl_errno ($ch)){returnCurl_error ($ch);} Curl_close ($ch);//Closereturn $tmpinfo;} Curl Analog Post SubmissionfunctionHttps_request ($url,$data=NULL){     $curl=Curl_init (); curl_setopt ($curl, Curlopt_url,$url); curl_setopt ($curl, Curlopt_ssl_verifypeer,FALSE); curl_setopt ($curl, Curlopt_ssl_verifyhost,FALSE); if(!Empty($data) {curl_setopt ($curl, Curlopt_post, 1); curl_setopt ($curl, Curlopt_postfields,$data); } curl_setopt ($curl, Curlopt_returntransfer, 1); $output= Curl_exec ($curl); Curl_close ($curl); return $output;}

CURL Analog HTTP Commit

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.