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

The curl_init method returns a false if there is an error.

PHP Code:
public function sample()
{
 
   $ch curl_init();

 
   if ($ch !== false)
 
   {
 
       $target_url 'https://apiurl.com';
 
       curl_setopt($chCURLOPT_URL,$target_url);
 
       curl_setopt($chCURLOPT_POST,1);
 
       curl_setopt($chCURLOPT_ENCODING'');
 
       $args['file'] = new CurlFile($_SERVER['DOCUMENT_ROOT'].'/file/'.'sample.docx');
 
       curl_setopt($chCURLOPT_POSTFIELDS$args);
 
       curl_setopt($chCURLOPT_RETURNTRANSFERTRUE); 
 
       curl_setopt($chCURLOPT_HEADERfalse);
 
       curl_setopt($chCURLOPT_SSL_VERIFYPEERfalse);
 
       curl_setopt($chCURLOPT_FOLLOWLOCATION1);

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

 
       print_r($response);
 
       die('--------------here-----------------');
 
   }
 
   else
    
{
 
       // ERROR
 
   }


Give that a try.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply


Messages In This Thread
cURL is not working with codeignier 3 - by dhaval - 07-24-2018, 11:13 PM
RE: cURL is not working with codeignier 3 - by InsiteFX - 07-25-2018, 03:28 AM



Theme © iAndrew 2016 - Forum software by © MyBB