コード例 #1
0
ファイル: Login.php プロジェクト: atanenl/twinfield
 /**
  * Will process the login.
  *
  * If successful, will set the session and cluster information
  * to the class
  *
  * @since 0.0.1
  *
  * @access public
  * @return boolean If successful or not
  * @throws \Pronamic\Twinfield\LoginException
  */
 public function process()
 {
     // Process logon
     if ($this->config->getClientToken() != '') {
         $response = $this->soapLoginClient->OAuthLogon($this->config->getCredentials());
         $result = $response->OAuthLogonResult;
     } else {
         $response = $this->soapLoginClient->Logon($this->config->getCredentials());
         $result = $response->LogonResult;
     }
     // Check response is successful
     if ($result == 'Ok') {
         // Response from the logon request
         $this->loginResponse = $this->soapLoginClient->__getLastResponse();
         // Make a new DOM and load the response XML
         $envelope = new \DOMDocument();
         $envelope->loadXML($this->loginResponse);
         // Gets SessionID
         $sessionID = $envelope->getElementsByTagName('SessionID');
         $this->sessionID = $sessionID->item(0)->textContent;
         // Gets Cluster URL
         $cluster = $envelope->getElementsByTagName('cluster');
         $this->cluster = $cluster->item(0)->textContent;
         // This login object is processed!
         $this->processed = true;
         return true;
     }
     throw new LoginException("Login error: " . $result);
 }