PHP code example of betsol / ipgeobase-client

1. Go to this page and download the library: Download betsol/ipgeobase-client library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

betsol / ipgeobase-client example snippets



// Creating a client:
$ipGeoBaseClient = new Betsol\IpGeoBase\Api\Client;

// You can pass API's base URL to it if e = $ipGeoBaseClient->lookupIp('93.184.216.119');

// Getting country:
$response->getCountry();
// "RU"

// Getting city:
$response->getCity();
// "Москва"

// Getting region:
$response->getRegion();
// "Москва"

// Getting district:
$response->getDistrict();
// "Центральный федеральный округ"

// Accessing IP range:
$ipRange = $response->getIpRange();

$ipRange->getStartIp();
// "213.180.200.192"

$ipRange->getEndIp();
// "213.180.208.255"

// Returning IP range as a string:
(string) $ipRange;
// "213.180.200.192 - 213.180.208.255"

// Accessing coordinates:
$coordinates = $response->getCoordinates()

$coordinates->getLatitude();
// float(55.755787)

$coordinates->getLongitude();
// float(37.617634)

// Returning coordinates as a string:
(string) $coordinates;
// string(20) "55.755787, 37.617634"