Hi antoine,
now i have a login system that it allow me to connect with API REST , and it’s running good using PHP CURL,my great problem is , how to adapt this information from bonita documentation in my code.
Create a new user
Request url POST |/API/identity/user
Request payload
{
“userName”:“New.User”,
“password”:“bpm”,
“password_confirm”:“bpm”,
“icon”:“”,
“firstname”:“New”,
“lastname”:“User”,
“title”:“Mr”,
“job_title”:“Human resources benefits”,
“manager_id”:“3”,
“professional_data_address”:“Renwick Drive”,
“professional_data_city”:“Philadelphia”,
“professional_data_country”:“United States”,
“professional_data_zipcode”:“19108”,
“professional_data_state”:“PA”,
“professional_data_email":"walter.bates@acme.com”,
“professional_data_phone_number”:“484-302-5409”,
“professional_data_mobile_number”:“”,
“personnal_data_address”:“”,
“personnal_data_city”:“”,
“personnal_data_country”:“”,
“personnal_data_zipcode”:“”,
“personnal_data_state”:“”,
“personnal_data_email”:“”,
“personnal_data_phone_number”:“”,
“personnal_data_mobile_number”:“”
}
Response payload
{
“last_connection”:“”,
“created_by_user_id”:“4”,
“creation_date”:“2014-12-09 17:43:28.291”,
“id”:“101”,
“icon”:“/default/icon_user.png”,
“enabled”:“false”,
“title”:“Mr”,
“manager_id”:“3”,
“job_title”:“Human resources benefits”,
“userName”:“New.User”,
“lastname”:“New”,
“firstname”:“User”,
“password”:“”,
“last_update_date”:“2014-12-09 17:43:28.291”}
This is my PHP CODE:
$baseURL = 'http://localhost:8080/bonita/';
$username = $usuari;
$password = $password;
echo"<b>usuari:</b> ".$_POST['usuari'];
echo"<br>";
echo"<b>password:</b>".$_POST['password'];
echo"<br>";
$conexio = curl_init();
//Apertura sesio API REST
$data = array('username' => $username, 'password' => $password, 'redirect' => 'false');
curl_setopt($conexio, CURLOPT_URL, $baseURL.$log_in_out);
curl_setopt($conexio, CURLOPT_POST, 1);
curl_setopt($conexio, CURLOPT_POSTFIELDS,http_build_query($data));
curl_setopt($conexio, CURLOPT_RETURNTRANSFER, true);
curl_setopt($conexio, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_exec($conexio);
//user query
**curl_setopt($conexio, CURLOPT_URL, $baseURL.'API/identity/user/206');
curl_setopt($conexio, CURLOPT_POST, 0);
$response_post = curl_exec($conexio);**
curl_close($conexio);
if($response_post ==false){
echo"
there aren’t any response!
";
}
else{
echo"<br>";
echo "<DIV style='color:blue;font-size:15px;border-style:solid;position:relative'>".$response_post."</DIV>";
echo"<br>";
echo"<br>";
echo"<br>";
}
}