I have the following function:
public function create($dir, $input)
{
$data = ['data'=>$input];
$json = $this->call('POST', '/'.$dir, $data);
return $json;
}
And the following code through which I send data and receive the response:
require_once('../Rest_smp.php');
$data["name"] = "Test usereee";
$data["username"] = "4533434";
$data["email"] = "bla@email.com";
$data["spi_classified"] = "yes";
$data["country_id"] = 5;
$data["timezone_id"] = 9;
$data["language_id"] = 3;
$data["status"] = "active";
echo (new Rest_smp())->create('user', $data);
When I call the url the response is coming in the following format:
{"status":400,"status_message":"Username or email is already in use!"}
What I want, is to echo only the status message and put it in a condition like this:
if(status_message="what response is coming") {
do this;
}
Any help or idea would be appreciated.