Skip to content

Commit

Permalink
Updated README.md.
Browse files Browse the repository at this point in the history
  • Loading branch information
ip2location committed Jul 4, 2022
1 parent f2b83ad commit e4df311
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,16 @@ Sample codes are given in this project, under **controllers** folder. You may ru

### BIN Database
Use following codes in your application for get geolocation information.

```
// (optional) Define IP2Location database path. By default, the IP2LOCATION_DATABASE is pointed to *application/libraries/ip2location/IP2LOCATION-DB.BIN* if you choose not to change the original settings.
define('IP2LOCATION_DATABASE', '/path/to/ip2location/database');
$ipl = new IP2Location_lib();
$countryCode = $ipl->getCountryCode('8.8.8.8');
```

Below are the methods supported for BIN data file lookup.

```
$countryCode = $ipl->getCountryCode($ip);
$countryName = $ipl->getCountryName($ip);
$regionName = $ipl->getRegionName($ip);
Expand All @@ -61,10 +62,11 @@ Below are the methods supported for BIN data file lookup.
$usageType = $ipl->getUsageType($ip);
$addressType = $ipl->getAddressType($ip);
$category = $ipl->getCategory($ip);
```

### Web Service
Use following codes in your application for get geolocation information.

```
// (required) Define IP2Location API key.
define('IP2LOCATION_API_KEY', 'your_api_key');
Expand All @@ -82,6 +84,25 @@ Use following codes in your application for get geolocation information.
$ipl = new IP2Location_lib();
print_r ($ipl->getWebService('8.8.8.8'));
```

### IPTools
Use following codes in your application for get IPTools class information.
```
$ipl = new IP2Location_lib();
var_dump($ipl->isIpv4('8.8.8.8'));echo '<br>';
var_dump($ipl->isIpv6('2001:4860:4860::8888'));echo '<br>';
print_r($ipl->ipv4ToDecimal('8.8.8.8'));echo '<br>';
print_r($ipl->decimalToIpv4(134744072));echo '<br>';
print_r($ipl->ipv6ToDecimal('2001:4860:4860::8888'));echo '<br>';
print_r($ipl->decimalToIpv6('42541956123769884636017138956568135816'));echo '<br>';
print_r($ipl->ipv4ToCidr('8.0.0.0', '8.255.255.255'));echo '<br>';
print_r($ipl->cidrToIpv4('8.0.0.0/8'));echo '<br>';
print_r($ipl->ipv6ToCidr('2002:0000:0000:1234:abcd:ffff:c0a8:0000', '2002:0000:0000:1234:ffff:ffff:ffff:ffff'));echo '<br>';
print_r($ipl->cidrToIpv6('2002::1234:abcd:ffff:c0a8:101/64'));echo '<br>';
print_r($ipl->compressIpv6('2002:0000:0000:1234:FFFF:FFFF:FFFF:FFFF'));echo '<br>';
print_r($ipl->expandIpv6('2002::1234:FFFF:FFFF:FFFF:FFFF'));echo '<br>';
```

## Dependencies
This module requires IP2Location BIN data file or IP2Location API key to function. You may download the BIN data file at
Expand Down

0 comments on commit e4df311

Please sign in to comment.