$json_response = json_decode($response['body']); if (is_object($json_response) and property_exists($json_response, 'error')) { throw new FacebookUnexpectedErrorException((is_object($json_response->error) and property_exists($json_response->error, 'message')) ? $json_response->error->message : ''); }