Posted By

jferiante on 06/11/11


Tagged

curl function


Versions (?)

curl function


 / Published in: PHP
 

URL: curl

just a basic curl function

  1. function curlGetFileContents($url) {
  2. $ch = curl_init();
  3. $timeout = 0; // set to zero for no timeout
  4. curl_setopt ($ch, CURLOPT_URL, $url);
  5. curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
  6. curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
  7. $file_contents = curl_exec($ch); // take out the spaces of curl statement!!
  8. if (!$file_contents) {
  9. print_r(curl_getinfo($ch));
  10. die;
  11. }
  12. curl_close($ch);
  13. return $file_contents;
  14. }

Report this snippet  

You need to login to post a comment.