Code samples

PHP Example with Guzzle

//create a new guzzle client object
$client = new Guzzle\Http\Client();
	
//prepare the request
$request = $client->createRequest(
  "POST",
  "http://domain.eu-1.quentn.com/public/api/v1/cb/65",
  array(
    "Content-Type" => "application/json",
    "Authorization" => "Bearer 8hl_iDsJHXaTtMtL6c0EEsVIHxnSCASTcfV-rkC45Jk",
  ),
  json_encode(array(
    "mail" => "johndoe@example.com",
    "first_name" => "John",
    "family_name" => "Doe",
  ))
);	
	
try {
	
  //send the request 
  $response = $request->send();
	
  //decode the response body
  $resp_body = json_decode($response->getBody());
  if(!empty($resp_body->success)) {
						
    //call was successful
    echo "API call was successful";
  }
  else {
		
    //call failed			
    if(!empty($resp_body->error)) {
      echo "API call failed with error message: <br>";
      echo $resp_body->message;
    }		
    else {
      echo "Unknown error";	
    }
  }
}
catch(Exception $e) {
  echo "Service unavailable or authorization error";
  $e->getMessage();
}