Okay so this problem is bothering me quite a bit.
I've created a controller function in my CodeIgniter projects at [project_url]/admin/orderpicking/get_updated_statuses
function name: get_updated_statuses controller name: Orderpicking.php controller location: application/admin
Inside the controller all I have is
ob_start();
print_r('success');
file_put_contents('file.txt', ob_get_contents());
ob_end_clean();
to confirm that I am hitting the controller.
When I hit the controller directly from my browser, the file gets created with 'success' as the content.
When I use cURL from another project to hit the controller, nothing happens, the result is an empty string (I dont care about the result right now, but the file.txt file is no longer being created).
Code that calls the controller is as follows:
$data = array('datetime'=>new DateTime());
$header = array(
'Identification:Portal::ReadAPI', // TODO config
'Content-Type:application/x-www-form-urlencode'
);
$url = '[local instance]/admin/orderpicking/get_updated_statuses'; // TODO config
$curlGetUpdatedItems = curl_init($url);
/** CURL OPTIONS */
curl_setopt($curlGetUpdatedItems, CURLOPT_POST, 1);
curl_setopt($curlGetUpdatedItems, CURLOPT_POSTFIELDS, json_encode(serialize($data)));
curl_setopt($curlGetUpdatedItems, CURLOPT_HTTPHEADER, $header);
curl_setopt($curlGetUpdatedItems, CURLOPT_RETURNTRANSFER, true);
// curl_setopt($curlGetUpdatedItems, CURLOPT_SSL_VERIFYPEER, true);
// curl_setopt($curlGetUpdatedItems, CURLOPT_SSL_VERIFYHOST, 2);
// curl_setopt($curlGetUpdatedItems, CURLOPT_CAINFO, $certificate_location);
/** CURL OPTIONS */
$result = curl_exec($curlGetUpdatedItems);
Are there any obvious mistakes I'm making here? I will add in a certificate later when I make the portal https but until then I don't think I need it?
Any help and/or advice is extremely welcome!
----- UPDATE -----
After var_dump'ing the result I've noticed that a boolean true is returned.
curl_error($curlGetUpdatedItems)
returns an empty string.