A simple php curl class-PHP source code

Source: Internet
Author: User
A simple php curl class I wrote a CURL-based PHP5 class, which has simple functions and is suitable for learning. If you really want to use it, it is absolutely recommended that Snoopy be too powerful. Although it is not based on curl.

Php code

 Render_postfields ($ vars); // url for generating urlcode $ array [CURLOPT_POST] = true; $ array [CURLOPT_POSTFIELDS] = $ postfields;} // checks whether a cookie exists, if yes, use if ($ _ COOKIE ['cookie _ jar'] | is_file ($ _ cookie ['cookie _ jar']). {$ array [CURLOPT_COOKIEFILE] = $ _ COOKIE ['cookie _ jar']; // Determine the cookie here} else {$ cookie_jar = tempnam ('/tmp ', 'cookies'); // Generate a cookie file $ array [CURLOPT_COOKIEJAR] = $ cookie_jar; // write a cookie Setcookie ('cookie _ jar', $ cookie_jar); // Save the cookie path} curl_setopt_array ($ ch, $ array ); // input the curl parameter $ content = curl_exec ($ ch); // execute curl_close ($ ch); // Close return $ content; // return} protected function render_postfields ($ vars) {foreach ($ vars as $ key => $ values) {$ postdata. = urlencode ($ key ). "= ". urlencode ($ values ). "&" ;}return $ postdata ;}}?>

Usage

 Go ('http: // www.renren.com/PLogin.do', $ vars);} else {?>    
 

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.