Welcome Guest, Not a member yet? Register   Sign In
cURL is not working with codeignier 3
#1

In CodeIgniter 3.1.8.  I used cURL.

Code:
public function sample()
{
   $ch = curl_init();
   $target_url = 'https://apiurl.com';
   curl_setopt($ch, CURLOPT_URL,$target_url);
   curl_setopt($ch, CURLOPT_POST,1);
   curl_setopt($ch, CURLOPT_ENCODING, '');
   $args['file'] = new CurlFile($_SERVER['DOCUMENT_ROOT'].'/file/'.'sample.docx');
   curl_setopt($ch, CURLOPT_POSTFIELDS, $args);
   curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
   curl_setopt($ch, CURLOPT_HEADER, false);
   curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
   curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);

   $response = curl_exec($ch);
   if ($response === false) {  
      print_r('Curl error: ' . curl_error($ch));
      die;
   }

   print_r($response);
   die('--------------here-----------------');

}

I can not get any error or response from that.
but the same code is working outside of Codeigniter.
should I use an external library for that? or Should I make some changes to the code?
I checked this one https://github.com/philsturgeon/codeigniter-curl but it is DEPRECATED.
Reply


Messages In This Thread
cURL is not working with codeignier 3 - by dhaval - 07-24-2018, 11:13 PM



Theme © iAndrew 2016 - Forum software by © MyBB