src/Autodiscover.php
public function newEWS()
    {
        // Discovery not yet attempted.
        if ($this->discovered === null) {
            $this->discover();
        }

        // Discovery not successful.
        if ($this->discovered === false) {
            return false;
        }

        $server = false;
        $version = null;

        // Pick out the host from the EXPR (Exchange RPC over HTTP).
        foreach ($this->discovered['Account']['Protocol'] as $protocol) {
            if (($protocol['Type'] == 'EXCH' || $protocol['Type'] == 'EXPR')
                && isset($protocol['ServerVersion'])) {
                if ($version === null) {
                    $sv = $this->parseServerVersion($protocol['ServerVersion']);
                    if ($sv !== false) {
                        $version = $sv;
                    }
                }
            }

            if ($protocol['Type'] == 'EXPR' && isset($protocol['Server'])) {
                $server = $protocol['Server'];
            }
        }

        if ($server) {
            if ($version === null) {
                // EWS class default.
                $version = Client::VERSION_2007;
            }
            return new Client(
                $server,
                (!empty($this->username) ? $this->username : $this->email),
                $this->password,
                $version
            );
        }

        return false;
    }
public function newEWS()
    {
        // Discovery not yet attempted.
        if ($this->discovered === null) {
            $this->discover();
        }

        // Discovery not successful.
        if ($this->discovered === false) {
            return false;
        }

        $server = false;
        $version = null;

        // Pick out the host from the EXPR (Exchange RPC over HTTP).
        foreach ($this->discovered['Account']['Protocol'] as $protocol) {
            if (($protocol['Type'] == 'EXCH' || $protocol['Type'] == 'EXPR')
                && isset($protocol['ServerVersion'])) {
                if ($version === null) {
                    $sv = $this->parseServerVersion($protocol['ServerVersion']);
                    if ($sv !== false) {
                        $version = $sv;
                    }
                }
            }

            if ($protocol['Type'] == 'EXPR' && isset($protocol['Server'])) {
                $server = $protocol['Server'];
            }
        }

        if ($server) {
            if ($version === null) {
                // EWS class default.
                $version = Client::VERSION_2007;
            }
            return new Client(
                $server,
                (!empty($this->username) ? $this->username : $this->email),
                $this->password,
                $version
            );
        }

        return false;
    }
public function newEWS ( ) { // Discovery not yet attempted. if ( $ this -> discovered === null ) { $ this -> discover ( ) ; } // Discovery not successful. if ( $ this -> discovered === false ) { return false ; } $ server = false ; $ version = null ; // Pick out the host from the EXPR (Exchange RPC over HTTP). foreach ( $ this -> discovered [ 'Account' ] [ 'Protocol' ] as $ protocol ) { if ( ( $ protocol [ 'Type' ] == 'EXCH' || $ protocol [ 'Type' ] == 'EXPR' ) && isset ( $ protocol [ 'ServerVersion' ] ) ) { if ( $ version === null ) { $ sv = $ this -> parseServerVersion ( $ protocol [ 'ServerVersion' ] ) ; if ( $ sv !== false ) { $ version = $ sv ; } } } if ( $ protocol [ 'Type' ] == 'EXPR' && isset ( $ protocol [ 'Server' ] ) ) { $ server = $ protocol [ 'Server' ] ; } } if ( $ server ) { if ( $ version === null ) { // EWS class default. $ version = Client :: VERSION_2007 ; } return new Client ( $ server , ( ! empty ( $ this -> username ) ? $ this -> username : $ this -> email ) , $ this -> password , $ version ) ; } return false ; }
Method to return a new Client object, auto-configured
with the proper hostname.

@return mixed Client object on success, FALSE on failure.
Method to return a new Client object auto - configured with the proper hostname .