Moodle PHP Documentation 4.3
Moodle 4.3.5 (Build: 20240610) (7dcfaa79f78)
GeoIp2\WebService\Client Class Reference
Inheritance diagram for GeoIp2\WebService\Client:
GeoIp2\ProviderInterface

Public Member Functions

 __construct (int $accountId, string $licenseKey, array $locales=['en'], array $options=[])
 Constructor.
 
 city (string $ipAddress='me')
 This method calls the City Plus service.
 
 country (string $ipAddress='me')
 This method calls the Country service.
 
 insights (string $ipAddress='me')
 This method calls the Insights service.
 

Public Attributes

const VERSION = 'v2.13.0'
 

Constructor & Destructor Documentation

◆ __construct()

GeoIp2\WebService\Client::__construct ( int $accountId,
string $licenseKey,
array $locales = ['en'],
array $options = [] )

Constructor.

Parameters
int$accountIdyour MaxMind account ID
string$licenseKeyyour MaxMind license key
array$localeslist of locale codes to use in name property from most preferred to least preferred
array$optionsarray of options. Valid options include:
  • host - The host to use when querying the web service. To query the GeoLite2 web service instead of the GeoIP2 web service, set the host to geolite.info.
  • 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.

Member Function Documentation

◆ city()

GeoIp2\WebService\Client::city ( string $ipAddress = 'me')

This method calls the City Plus service.

Parameters
string$ipAddressIPv4 or IPv6 address as a string. If no address is provided, the address that the web service is called from will be used.
Exceptions
GeoIp2\Exception\AddressNotFoundExceptionif the address you provided is not in our database (e.g., a private address).
GeoIp2\Exception\AuthenticationExceptionif there is a problem with the account ID or license key that you provided
GeoIp2\Exception\OutOfQueriesExceptionif your account is out of queries
GeoIp2\Exception\InvalidRequestException}if your request was received by the web service but is invalid for some other reason. This may indicate an issue with this API. Please report the error to MaxMind.
GeoIp2\Exception\HttpExceptionif an unexpected HTTP error code or message was returned. This could indicate a problem with the connection between your server and the web service or that the web service returned an invalid document or 500 error code
GeoIp2\Exception\GeoIp2ExceptionThis serves as the parent class to the above exceptions. It will be thrown directly if a 200 status code is returned but the body is invalid.

Implements GeoIp2\ProviderInterface.

◆ country()

GeoIp2\WebService\Client::country ( string $ipAddress = 'me')

This method calls the Country service.

Parameters
string$ipAddressIPv4 or IPv6 address as a string. If no address is provided, the address that the web service is called from will be used.
Exceptions
GeoIp2\Exception\AddressNotFoundExceptionif the address you provided is not in our database (e.g., a private address).
GeoIp2\Exception\AuthenticationExceptionif there is a problem with the account ID or license key that you provided
GeoIp2\Exception\OutOfQueriesExceptionif your account is out of queries
GeoIp2\Exception\InvalidRequestException}if your request was received by the web service but is invalid for some other reason. This may indicate an issue with this API. Please report the error to MaxMind.
GeoIp2\Exception\HttpExceptionif an unexpected HTTP error code or message was returned. This could indicate a problem with the connection between your server and the web service or that the web service returned an invalid document or 500 error code.
GeoIp2\Exception\GeoIp2ExceptionThis serves as the parent class to the above exceptions. It will be thrown directly if a 200 status code is returned but the body is invalid.

Implements GeoIp2\ProviderInterface.

◆ insights()

GeoIp2\WebService\Client::insights ( string $ipAddress = 'me')

This method calls the Insights service.

Insights is only supported by the GeoIP2 web service. The GeoLite2 web service does not support it.

Parameters
string$ipAddressIPv4 or IPv6 address as a string. If no address is provided, the address that the web service is called from will be used.
Exceptions
GeoIp2\Exception\AddressNotFoundExceptionif the address you provided is not in our database (e.g., a private address).
GeoIp2\Exception\AuthenticationExceptionif there is a problem with the account ID or license key that you provided
GeoIp2\Exception\OutOfQueriesExceptionif your account is out of queries
GeoIp2\Exception\InvalidRequestException}if your request was received by the web service but is invalid for some other reason. This may indicate an issue with this API. Please report the error to MaxMind.
GeoIp2\Exception\HttpExceptionif an unexpected HTTP error code or message was returned. This could indicate a problem with the connection between your server and the web service or that the web service returned an invalid document or 500 error code
GeoIp2\Exception\GeoIp2ExceptionThis serves as the parent class to the above exceptions. It will be thrown directly if a 200 status code is returned but the body is invalid.

The documentation for this class was generated from the following file: