Example #1
0
 public function login($email, $pass, $options = array())
 {
     // Import the supplied options.
     $this->options = array_merge($this->options, $options);
     // Debug
     $this->error("Logging in as {$email} to {$this->options['alias']}.");
     $url_header = @get_headers($this->getUrl());
     if ($url_header[0] == 'HTTP/1.1 404 Not Found' || !$url_header) {
         return false;
     }
     // Authenticating and save session key
     $authClient = new SoapClient($this->getUrl(), $this->soap_options);
     $response = $authClient->AuthenticateWebSafe(array('email' => $email, 'pass' => $pass));
     // Bad login case
     if ($response->AuthenticateWebSafeResult->Code == "Not_Found") {
         return false;
     } else {
         if ($response->AuthenticateWebSafeResult->Code == "Success") {
             // Save the session key in class and session
             $this->VeetroSession = $response->AuthenticateWebSafeResult->SessionKey;
             $this->User = $response;
             $this->session('VeetroSession', $this->VeetroSession);
             $this->session('UserID', (string) $response->AuthenticateWebSafeResult->User->EntityID);
             $this->session('User', $response->AuthenticateWebSafeResult->User);
             $this->error("Saving new session key {$this->VeetroSession}.");
             // Connect to api with VeetroHeader.
             $this->connect();
             return true;
         } else {
             $this->error("Unknown auth response code: {$response->AuthenticateWebSafeResult->Code}", self::ERROR);
             die(print_r($response, true));
         }
     }
 }