Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.10.x will end 8 November 2021 (12 months).
  • Bug fixes for security issues in 3.10.x will end 9 May 2022 (18 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

Differences Between: [Versions 310 and 311] [Versions 310 and 400] [Versions 310 and 401] [Versions 310 and 402] [Versions 310 and 403]

(no description)

File Size: 239 lines (12 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

Client:: (6 methods):
  __construct()
  userAgent()
  city()
  country()
  insights()
  responseFor()


Class: Client  - X-Ref

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.

Each web service is represented by a different model class, and these model
classes in turn contain multiple record classes. The record classes have
attributes which contain data about the IP address.

If the web service does not return a particular piece of data for an IP
address, the associated attribute is not populated.

The web service may not return any information for an entire record, in
which case all of the attributes for that record class will be empty.

## Usage ##

The basic API for this class is the same for all of the web service end
points. First you create a web service object with your MaxMind `$accountId`
and `$licenseKey`, then you call the method corresponding to a specific end
point, passing it the IP address you want to look up.

If the request succeeds, the method call will return a model class for
the service you called. This model in turn contains multiple record
classes, each of which represents part of the data returned by the web
service.

If the request fails, the client class throws an exception.
__construct($accountId,$licenseKey,$locales = ['en'],$options = [])   X-Ref
Constructor.

param: int    $accountId  your MaxMind account ID
param: string $licenseKey your MaxMind license key
param: array  $locales    list of locale codes to use in name property
param: array  $options    array of options. Valid options include:

userAgent()   X-Ref
No description

city($ipAddress = 'me')   X-Ref
This method calls the GeoIP2 Precision: City service.

param: string $ipAddress IPv4 or IPv6 address as a string. If no
return: \GeoIp2\Model\City

country($ipAddress = 'me')   X-Ref
This method calls the GeoIP2 Precision: Country service.

param: string $ipAddress IPv4 or IPv6 address as a string. If no
return: \GeoIp2\Model\Country

insights($ipAddress = 'me')   X-Ref
This method calls the GeoIP2 Precision: Insights service.

param: string $ipAddress IPv4 or IPv6 address as a string. If no
return: \GeoIp2\Model\Insights

responseFor($endpoint, $class, $ipAddress)   X-Ref
No description