Posted By

ryantxr on 06/13/13


Tagged

curl


Versions (?)

Curl for PHP


 / Published in: PHP
 

minimal curl code for php

  1. $request = curl_init($url); // initiate curl object
  2. curl_setopt($request, CURLOPT_HEADER, 0); // set to 1 to get the header info in the response
  3. curl_setopt($request, CURLOPT_RETURNTRANSFER, 1); // Returns response data instead of TRUE(1)
  4. curl_setopt($request, CURLOPT_POSTFIELDS, $postData); // use HTTP POST to send form data
  5.  
  6. //curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE);
  7. if ( preg_match('/^https/', $url) ) {
  8. curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE);
  9. curl_setopt($request, CURLOPT_SSL_VERIFYHOST, FALSE);
  10. }
  11.  
  12. // execute curl post and store results in $post_response
  13. if( ! $result = curl_exec($request) ){
  14.  
  15. }

Report this snippet  

You need to login to post a comment.