我正在尝试在php中获取json数据
{
"message":"otp verified",
"type":"success"
}
我尝试过以下代码来解析JSON数据
public function verify_register_otp(){
$otp = $_POST['otp'];
$api_key= $this->config->get('synicsys_working_key');
$sender_id= $this->config->get('synicsys_sender_id');
$mob_num= $this->config->get('synicsys_admin1');
$sms = new Synicsys();
$response= $sms->verify($mob_num,$otp,$api_key);
$json = json_decode($response,true);
return $json[1]->type;
}
我遇到以下错误
{"message":"otp_not_verified","type":"error"}<b>Notice</b>: Trying to get property of non-object