@@ -32,15 +32,15 @@ Install-Package MaxMind.GeoIP2
3232< dependency>
3333 < groupId> com. maxmind. geoip2< / groupId>
3434 < artifactId> geoip2< / artifactId>
35- < version> 2.15 . 0 < / version>
35+ < version> 5.0 . 2 < / version>
3636< / dependency>
3737
3838// Or install via Gradle
3939repositories {
4040 mavenCentral()
4141}
4242dependencies {
43- compile ' com.maxmind.geoip2:geoip2:2.15.0 '
43+ implementation ' com.maxmind.geoip2:geoip2:5.0.2 '
4444}
4545```
4646
@@ -54,7 +54,7 @@ yarn add @maxmind/geoip2-node
5454
5555``` php
5656# Install via Composer
57- composer require geoip2/geoip2:~2 .0
57+ composer require geoip2/geoip2:~3 .0
5858```
5959
6060``` python
@@ -122,23 +122,23 @@ const client = new WebServiceClient(accountId, licenseKey, {
122122```
123123
124124``` php
125- <?php require_once 'vendor/autoload.php'
125+ <?php
126+ require_once 'vendor/autoload.php';
126127use GeoIp2\WebService\Client;
127128
128- $account_id = 10;
129- $license_key = 'LICENSEKEY';
129+ $accountId = 10;
130+ $licenseKey = 'LICENSEKEY';
130131
131- $client = new Client($account_id , $license_key );
132+ $client = new Client($accountId , $licenseKey );
132133
133134// To query the GeoLite web service, you must set the optional `host` argument.
134135// The third argument specifies the language preferences when using the `->name`
135136// method on the model classes that this client creates.
136- $client = new Client($account_id , $license_key , ['en'], ['host' => 'geolite.info']);
137+ $client = new Client($accountId , $licenseKey , ['en'], ['host' => 'geolite.info']);
137138```
138139
139140``` python
140- import asyncio # for async requests with AsyncClient
141- import geoip2.webservice
141+ from geoip2.webservice import Client, AsyncClient
142142
143143account_id = 10
144144license_key = ' LICENSEKEY'
@@ -150,7 +150,7 @@ client = Client(account_id, license_key)
150150# to "geolite.info"
151151client = Client(account_id, license_key, host = ' geolite.info' )
152152
153- # Or if you want to use asynchronous requests
153+ # Or if you want to use asynchronous requests (requires `import asyncio`)
154154async_client = AsyncClient(account_id, license_key)
155155
156156# To query the GeoLite web service, you must set the "host" keyword argument
@@ -227,10 +227,10 @@ try (WebServiceClient client = new WebServiceClient.Builder(accountId, licenseKe
227227 // `client.insights` is not available to GeoLite users
228228 CountryResponse response = client. country(ipAddress);
229229
230- Country country = response. getCountry ();
231- System . out. println(country. getIsoCode ()); // 'US'
232- System . out. println(country. getName ()); // 'United States'
233- System . out. println(country. getNames (). get(" zh-CN" )); // '美国'
230+ Country country = response. country ();
231+ System . out. println(country. isoCode ()); // 'US'
232+ System . out. println(country. name ()); // 'United States'
233+ System . out. println(country. names (). get(" zh-CN" )); // '美国'
234234}
235235```
236236
@@ -239,6 +239,11 @@ const WebServiceClient = require('@maxmind/geoip2-node').WebServiceClient;
239239// Typescript:
240240// import { WebServiceClient } from '@maxmind/geoip2-node';
241241
242+ const accountId = ' 10' ;
243+ const licenseKey = ' LICENSEKEY' ;
244+
245+ const client = new WebServiceClient (accountId, licenseKey);
246+
242247// You can also use `client.city` or `client.insights`
243248// `client.insights` is not available to GeoLite users
244249client .country (' 142.1.1.1' ).then ((response ) => {
@@ -247,13 +252,14 @@ client.country('142.1.1.1').then((response) => {
247252```
248253
249254``` php
250- <?php require_once 'vendor/autoload.php'
255+ <?php
256+ require_once 'vendor/autoload.php';
251257use GeoIp2\WebService\Client;
252258
253- $account_id = 10;
254- $license_key = 'LICENSEKEY';
259+ $accountId = 10;
260+ $licenseKey = 'LICENSEKEY';
255261
256- $client = new Client($account_id , $license_key );
262+ $client = new Client($accountId , $licenseKey );
257263
258264// You can also use `$client->city` or `$client->insights`
259265// `$client->insights` is not available to GeoLite users
@@ -264,27 +270,27 @@ print($record->country->isoCode . "\n");
264270
265271``` python
266272# Sync
267- import geoip2.webservice
273+ from geoip2.webservice import Client
268274
269275account_id = 10
270276license_key = ' LICENSEKEY'
271277
272- with geoip2.webservice. Client(account_id, license_key) as client:
278+ with Client(account_id, license_key) as client:
273279 # You can also use `client.city` or `client.insights`
274280 # `client.insights` is not available to GeoLite users
275- response = client.country(' 128.101.101.101)
281+ response = client.country(' 128.101.101.101' )
276282
277283 print (response.country.iso_code)
278284
279285# Async
280286import asyncio
281- import geoip2.webservice
287+ from geoip2.webservice import AsyncClient
282288
283289async def main ():
284- async with geoip2.webservice. AsyncClient(account_id, license_key) as client:
290+ async with AsyncClient(account_id, license_key) as client:
285291 # You can also use `client.city` or `client.insights`
286292 # `client.insights` is not available to GeoLite users
287- response = await client.country(' 128.101.101.101)
293+ response = await client.country(' 128.101.101.101' )
288294
289295 print (response.country.iso_code)
290296
0 commit comments