0

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.

deceze
  • 510,633
  • 85
  • 743
  • 889
user1147188
  • 135
  • 2
  • 3
  • 12
  • it's not a duplicate question because it approaches the problem different. Read it, understand it and then give your opinion. – user1147188 Aug 28 '18 at 11:35
  • What exactly is supposedly different? Spell it out for us so we can help you in a targeted way. – deceze Aug 28 '18 at 11:36

0 Answers0