You are here

public function Client::__construct in Smart IP 6.2

Same name in this branch
  1. 6.2 includes/vendor/maxmind/web-service-common/src/WebService/Client.php \MaxMind\WebService\Client::__construct()
  2. 6.2 includes/vendor/geoip2/geoip2/src/WebService/Client.php \GeoIp2\WebService\Client::__construct()
Same name and namespace in other branches
  1. 7.2 includes/vendor/geoip2/geoip2/src/WebService/Client.php \GeoIp2\WebService\Client::__construct()

Constructor.

Parameters

int $userId Your MaxMind user ID:

string $licenseKey Your MaxMind license key:

array $locales List of locale codes to use in name property: from most preferred to least preferred.

array $options Array of options. Valid options include::

  • `host` - The host to use when querying the web service.
  • `timeout` - Timeout in seconds.
  • `connectTimeout` - Initial connection timeout in seconds.
  • `proxy` - The HTTP proxy to use. May include a schema, port, username, and password, e.g., `http://username:password@127.0.0.1:10`.

File

includes/vendor/geoip2/geoip2/src/WebService/Client.php, line 68

Class

Client
This class provides a client API for all the GeoIP2 Precision web services. The services are Country, City, and Insights. Each service returns a different set of data about an IP address, with Country returning the least data and Insights the most.

Namespace

GeoIp2\WebService

Code

public function __construct($userId, $licenseKey, $locales = array(
  'en',
), $options = array()) {
  $this->locales = $locales;

  // This is for backwards compatibility. Do not remove except for a
  // major version bump.
  if (is_string($options)) {
    $options = array(
      'host' => $options,
    );
  }
  if (!isset($options['host'])) {
    $options['host'] = 'geoip.maxmind.com';
  }
  $options['userAgent'] = $this
    ->userAgent();
  $this->client = new WsClient($userId, $licenseKey, $options);
}