/** * Remove a user with OneLogin API * @throws Exception * * @example Add a line when deleting a user * @link http://jsfiddle.net/davidThomas/DynyP/1/ * */ public function olDeleteAsyncAction() { // No need to render $this->_helper->viewRenderer->setNoRender(); // Create json object $json = new stdClass(); $json->error = 0; $json->message = ""; // The entire process try { // Get parameters $userId = $this->_getParam("id"); // Create API instance and remove the user $users = new OneLogin_Api_Users(); $response = $users->deleteUser($userId); if ($response->isSuccessful()) { $message = 'User removed ' . str_replace("'", '', trim($response->getMessage())); $json->message = $message; } else { throw new Exception($response->getMessage()); } } catch (Exception $e) { $json->error = 1; $json->message = str_replace("'", '', trim($e->getMessage())); } echo $this->_helper->json($json); // Send response }