PUT 204 status - cURL PHP

Regular Participant

PUT 204 status - cURL PHP

I was hoping someone could help me out here. I have a php script using cURL to GET, POST, and PUT. Per the documentation a PUT should return a 204 status. My problem is that the api (or my code) seems to be a hit and miss thing. My PUT works one minute and the next it does not. How can I check for a true 204 (successful) PUT? I have tried to check for a !$response from the curl_exec but this triggers my code regardless of whether it was successful or not. here is my code..
$request = $ccuri;
$session = curl_init($request);
$userNamePassword = $usrpsw;
curl_setopt($session, CURLOPT_USERPWD, $userNamePassword);
curl_setopt($session, CURLOPT_FOLLOWLOCATION ,1);
curl_setopt($session, CURLOPT_CUSTOMREQUEST,"PUT");
curl_setopt($session, CURLOPT_POSTFIELDS , $entry);
curl_setopt($session, CURLOPT_HTTPHEADER, Array("Content-Type:application/atom+xml"));
curl_setopt($session, CURLOPT_HEADER, 0);
curl_setopt($session, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($session, CURLOPT_HTTP_VERSION, 1.0);
$response = curl_exec($session);

if(!$response) {return true;}
else {return false;}

I have tried to use
$status = array();
preg_match('/HTTP\/.* (+) .*/', $response, $status);
if ($status = 204) { return true; }

but actually I get no response even when it works.

Can I suggest adding some PUT examples up on the site. You have each kind of example except PUT.
Frequent Participant

Short Put example posted in the Getting Started/Samples Forum here.
Tom M
Group Product Manager – Content Editing
Constant Contact
Developer Portal

View API documentation, code samples, get your API key.

Visit Page