I'm using PHP to send an HTML post request using curl. I want to add more data to an existing JSON array at an URL. If I post a request, does it replace the data or does it add it to the existing array? Currently, I'm writing:
// Setup cURL
$ch = curl_init('http://www.barn-door.co.uk/wp-json/geodir/v1/farms');
curl_setopt_array($ch, array(
CURLOPT_POST => TRUE,
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_HTTPHEADER => array(
'Authorization: '.$authToken,
'Content-Type: application/json'
),
CURLOPT_POSTFIELDS => json_encode($postData)
));
// Send the request
$response = curl_exec($ch);
// Check for errors
if($response === FALSE){
die(curl_error($ch));
}
// Decode the response
$responseData = json_decode($response, TRUE);
// Print the date from the response
echo $responseData['published'];
where $postData is my data in json format.
Thanks :)