I have an issue with a form I am trying to POST to a PHP page which then CURLs it to a Slim API endpoint but for some reason (done a lot of searching and trying different methods) I can't seem to get the form arrays to send to Slim.
header('Content-Type: application/json');
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "http://endpoint/add",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => array(
'first_name' => $_POST['user']['first_name'],
'last_name' => $_POST['user']['last_name'],
'conditions[]' => '1',
'conditions[]' => '2',
'conditions[]' => '3'
),
CURLOPT_HTTPHEADER => array(
"Authorization: Bearer " . $_POST['token'],
"cache-control: no-cache",
"content-type: multipart/form-data"
),
));
When I test this in Postman the data submits correctly however when using it online for some reason I'm either only getting the last "conditions" value (3) or a string "Array". I see this by var_dump on the Slim API side.
As mentioned, I know Slim works as when I POST in Postman everything submits correctly.
Any suggestions?