从json响应中回显某些变量

时间:2018-08-28 11:22:36

标签: php rest web-services

我具有以下功能:

public function create($dir, $input)
{   
    $data = ['data'=>$input];           
    $json = $this->call('POST', '/'.$dir, $data);
    return $json;
}

还有以下代码,通过这些代码我可以发送数据并接收响应:

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);

当我调用url时,响应将以以下格式出现:

{"status":400,"status_message":"Username or email is already in use!"}

我想要的是仅回显状态消息并将其置于这样的状态:

if(status_message="what response is coming") {   
    do this;  
} 

任何帮助或想法都将不胜感激。

0 个答案:

没有答案