/** * Returns the server info. * * @param int $serverId * @param string $section self::SERVER_INFO_* * @return DataObject * * @throws \InvalidArgumentException */ public function getServerInfo($serverId, $section) { switch ($section) { case self::SERVER_INFO_WEB: $dataObject = 'Web'; break; // TODO implement other sections // TODO implement other sections default: throw new \InvalidArgumentException("Invalid \$section parameter value '{$section}'."); } $data = $this->server->server_get($this->sessionId, $serverId, $section); $dataObject = __NAMESPACE__ . '\\Data\\Server\\' . $dataObject; return $dataObject::fromData($data); }
protected function loadData() { $client = new SoapClient(null, array('location' => SOAP_LOCATION, 'uri' => SOAP_URI)); try { //* Login to the remote server if ($session_id = $client->login(SOAP_USER, SOAP_PASS)) { $mail_user = $client->mail_user_get($session_id, array('email' => $this->email)); if (count($mail_user) == 1) { $this->host = $client->server_get($session_id, $mail_user[0]['server_id'], 'server'); $this->user = $mail_user[0]; } else { throw new Exception("Unknown Account"); } } //* Logout $client->logout($session_id); } catch (SoapFault $e) { throw new Exception('SOAP Error: ' . $e->getMessage()); } }
<?php require 'soap_config.php'; $client = new SoapClient(null, array('location' => $soap_location, 'uri' => $soap_uri, 'trace' => 1, 'exceptions' => 1)); try { if ($session_id = $client->login($username, $password)) { echo 'Logged successfull. Session ID:' . $session_id . '<br />'; } //* Set the function parameters. $server_id = 1; $record_record = $client->server_get($session_id, $server_id, $section = ''); print_r($record_record); echo "<br>"; if ($client->logout($session_id)) { echo 'Logged out.<br />'; } } catch (SoapFault $e) { echo $client->__getLastResponse(); die('SOAP Error: ' . $e->getMessage()); }