I'm having simple script which comunicate via REST with some server.
Server architecture have some holes, and I fight with one of them right now.
When I send one request to assign some profile and don't wait for response and send second request.
It basicly just scrap the first request and do the second one only.
My code looks like:
$this->assignProfile($token, $id, FIRST);
$this->assignProfile($token, $id, SECOND);
My Assign profile method looks like:
public function assignProfile($token, $organizationId, $profileId)
{
//define enviroment and path
$host = enviroment;
$path = "/admin/members/".$organizationId."/assigned-profiles";
$data_string = '["'.$profileId.'"]';
// set up the curl resource
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $host.$path);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Authorization: Bearer '.$token.'',
'Content-Length: ' . strlen($data_string)
));
echo "<br>OK<br>";
// execute the request
$output = curl_exec($ch);
curl_close($ch);
}
The thing is, webservice is not response with any body or something, it just response with code 200. How can I code this to wait for a 200 and than continue with second request.