/** * List all OneLogin user via API * @throws Exception */ public function olListAsyncAction() { // Disable layout $this->_helper->layout->disableLayout(); $this->view->users = null; try { // Create API instance and get the user list $users = new OneLogin_Api_Users(); $response = $users->listUsers(); if ($response->isSuccessful()) { //echo $xmlResult; $xmlResult = simplexml_load_string($response->getBody()); } else { throw new Exception($response->getMessage()); } // Define what XMLElements we are using $elementsDisplayed = array('id', 'openid-name', 'email', 'status', 'last-login'); // Process the XML into an array $users = array(); foreach ($xmlResult->children() as $child) { // Create new object $user = new stdClass(); // Get children foreach ($child->children() as $subChild) { if (in_array(strtolower($subChild->getName()), $elementsDisplayed)) { $property = str_replace('-', '', $subChild->getName()); //echo $property .':'.$subChild.'<br/>'; $user->{$property} = strip_tags($subChild); } } // Add object to array array_push($users, $user); } // end foreach // Sort array asort($users); // Send to view $this->view->users = $users; } catch (Exception $e) { throw new Exception($e->getMessage()); } }