public function lookupNorthstarUser($user)
  {
    $northstarAPIConfig = $this->mbConfig->getProperty('northstar_config');
    if (empty($northstarAPIConfig['host'])) {
      throw new Exception('MB_Toolbox->lookupNorthstarUser() northstar_config missing host setting.');
    }

    $northstarUrl =  $northstarAPIConfig['host'];

    // Append port if exists.
    if (!empty($northstarAPIConfig['port'])) {
      $port = (int) $northstarAPIConfig['port'];
      // Port is within allowed range:
      // https://en.wikipedia.org/wiki/Port_(computer_networking)#Details
      if ($port > 0 && $port < 65536) {
        $northstarUrl .= ':' . $port;
      }
    }

    // Api version.
    $northstarUrl .= '/' . self::NORTHSTAR_API_VERSION . '/';

    // Lookup by email.
    if (!empty($user->email)) {
      $endpoint = $northstarUrl . 'users/email/' . $user->email;
      $result = $this->mbToolboxcURL->curlGet($endpoint);

      try {
        $northstarUser = $this->parseNorthstarUserResponse($result);
        echo '- User loaded from Northstar by email: '
          . $user->email . PHP_EOL;
        return $northstarUser;
      } catch (Exception $e) {
        echo '- Coundn\'t load user from Northstar by email: '
          . $user->email . PHP_EOL;
      }
    }

    // Lookup by phone.
    if (!empty($user->mobile)) {
      $endpoint = $northstarUrl . 'users/mobile/' . $user->mobile;
      $result = $this->mbToolboxcURL->curlGet($endpoint);

      try {
        $northstarUser = $this->parseNorthstarUserResponse($result);
        echo '- User loaded from Northstar by mobile: '
          . $user->mobile . PHP_EOL;
        return $northstarUser;
      } catch (Exception $e) {
        echo '- Coundn\'t load user from Northstar by mobile: '
          . $user->mobile . PHP_EOL;
      }
    }

    return false;
  }
public function lookupNorthstarUser($user)
  {
    $northstarAPIConfig = $this->mbConfig->getProperty('northstar_config');
    if (empty($northstarAPIConfig['host'])) {
      throw new Exception('MB_Toolbox->lookupNorthstarUser() northstar_config missing host setting.');
    }

    $northstarUrl =  $northstarAPIConfig['host'];

    // Append port if exists.
    if (!empty($northstarAPIConfig['port'])) {
      $port = (int) $northstarAPIConfig['port'];
      // Port is within allowed range:
      // https://en.wikipedia.org/wiki/Port_(computer_networking)#Details
      if ($port > 0 && $port < 65536) {
        $northstarUrl .= ':' . $port;
      }
    }

    // Api version.
    $northstarUrl .= '/' . self::NORTHSTAR_API_VERSION . '/';

    // Lookup by email.
    if (!empty($user->email)) {
      $endpoint = $northstarUrl . 'users/email/' . $user->email;
      $result = $this->mbToolboxcURL->curlGet($endpoint);

      try {
        $northstarUser = $this->parseNorthstarUserResponse($result);
        echo '- User loaded from Northstar by email: '
          . $user->email . PHP_EOL;
        return $northstarUser;
      } catch (Exception $e) {
        echo '- Coundn\'t load user from Northstar by email: '
          . $user->email . PHP_EOL;
      }
    }

    // Lookup by phone.
    if (!empty($user->mobile)) {
      $endpoint = $northstarUrl . 'users/mobile/' . $user->mobile;
      $result = $this->mbToolboxcURL->curlGet($endpoint);

      try {
        $northstarUser = $this->parseNorthstarUserResponse($result);
        echo '- User loaded from Northstar by mobile: '
          . $user->mobile . PHP_EOL;
        return $northstarUser;
      } catch (Exception $e) {
        echo '- Coundn\'t load user from Northstar by mobile: '
          . $user->mobile . PHP_EOL;
      }
    }

    return false;
  }
public function lookupNorthstarUser ( $ user ) { $ northstarAPIConfig = $ this -> mbConfig -> getProperty ( 'northstar_config' ) ; if ( empty ( $ northstarAPIConfig [ 'host' ] ) ) { throw new Exception ( 'MB_Toolbox->lookupNorthstarUser() northstar_config missing host setting.' ) ; } $ northstarUrl = $ northstarAPIConfig [ 'host' ] ; // Append port if exists. if ( ! empty ( $ northstarAPIConfig [ 'port' ] ) ) { $ port = ( int ) $ northstarAPIConfig [ 'port' ] ; // Port is within allowed range: // https://en.wikipedia.org/wiki/Port_(computer_networking)#Details if ( $ port > 0 && $ port < 65536 ) { $ northstarUrl .= ':' . $ port ; } } // Api version. $ northstarUrl .= '/' . self :: NORTHSTAR_API_VERSION . '/' ; // Lookup by email. if ( ! empty ( $ user -> email ) ) { $ endpoint = $ northstarUrl . 'users/email/' . $ user -> email ; $ result = $ this -> mbToolboxcURL -> curlGet ( $ endpoint ) ; try { $ northstarUser = $ this -> parseNorthstarUserResponse ( $ result ) ; echo '- User loaded from Northstar by email: ' . $ user -> email . PHP_EOL ; return $ northstarUser ; } catch ( Exception $ e ) { echo '- Coundn\'t load user from Northstar by email: ' . $ user -> email . PHP_EOL ; } } // Lookup by phone. if ( ! empty ( $ user -> mobile ) ) { $ endpoint = $ northstarUrl . 'users/mobile/' . $ user -> mobile ; $ result = $ this -> mbToolboxcURL -> curlGet ( $ endpoint ) ; try { $ northstarUser = $ this -> parseNorthstarUserResponse ( $ result ) ; echo '- User loaded from Northstar by mobile: ' . $ user -> mobile . PHP_EOL ; return $ northstarUser ; } catch ( Exception $ e ) { echo '- Coundn\'t load user from Northstar by mobile: ' . $ user -> mobile . PHP_EOL ; } } return false ; }
Lookup user on Northstar.
Lookup user on Northstar .