cURL is not working with codeignier 3 |
Use below 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); $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE); if($httpcode == 200 || $httpcode == '200') { print_r($response); } else { echo "httpcode : ".$httpcode; if ($response === false) { print_r('<br />cURL error: ' . curl_error($ch)); $error_message = curl_strerror($errno); echo "<br />cURL error ({$errno}):\n {$error_message}"; } } } If its return httpcode than after follow below link for verify exact error : 1) https://developer.mozilla.org/en-US/docs...TTP/Status 2) http://php.net/manual/en/function.http-r...e-code.php So you can move further easily. |
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 Pertti - 07-25-2018, 12:59 AM
RE: cURL is not working with codeignier 3 - by dhaval - 07-25-2018, 01:13 AM
RE: cURL is not working with codeignier 3 - by Pertti - 07-25-2018, 01:47 AM
RE: cURL is not working with codeignier 3 - by InsiteFX - 07-25-2018, 03:28 AM
RE: cURL is not working with codeignier 3 - by excellentwebworld - 08-11-2018, 12:05 AM
RE: cURL is not working with codeignier 3 - by InsiteFX - 08-11-2018, 06:09 AM
RE: cURL is not working with codeignier 3 - by skunkbad - 08-11-2018, 03:30 PM
|