I have the following cURL PHP function that works correctly
curl_setopt_array($curl, array(
CURLOPT_URL => "http://example.com/api",
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"api\"\r\n\r\n123344\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--",
CURLOPT_HTTPHEADER => array(
"cache-control: no-cache",
"content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW"
),
));
I would like to build the CURLOPT_POSTFIELDS by hand so have tried to pass an array instead like so...
$data = array('api'=>'123344');
curl_setopt_array($curl, array(
CURLOPT_URL => "http://example.com/api",
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => $data,
CURLOPT_HTTPHEADER => array(
"cache-control: no-cache",
"content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW"
),
));
But this is not giving me any response, can anyone point out what I am doing wrong?
multipart/form-data." So don't do this yourself, let cURL handle it.