PHP code example of geolax / freeipapi
1. Go to this page and download the library: Download geolax/freeipapi 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/ */
geolax / freeipapi example snippets
'drivers' => [
'freeipapi' => [
'driver' => 'freeipapi',
'base_url' => env('GEOLOCATE_FREEIPAPI_URL', 'https://freeipapi.com'),
'api_key' => env('GEOLOCATE_FREEIPAPI_KEY'),
'server' => env('GEOLOCATE_FREEIPAPI_SERVER', 'free'),
'timeout' => 5,
],
],
use Geolax\Geolocate\Facades\Geolocate;
$result = Geolocate::lookup('1.1.1.1');
$result->ipAddress; // "1.1.1.1"
$result->countryName; // "Australia"
$result->countryCode; // "AU"
$result->cityName; // "Sydney"
$result->latitude; // -33.8688
$result->longitude; // 151.209
$result->timezone; // "Australia/Sydney"
$result->currency; // "AUD"
$result = Geolocate::lookup('1.1.1.1');
$result->raw['capital']; // "Canberra"
$result->raw['phoneCodes']; // [61]
$result->raw['timeZones']; // ["Australia/Sydney", "Australia/Melbourne", ...]
$result->raw['currencies']; // ["AUD"]
$result->raw['languages']; // ["en"]
$result->raw['asn']; // "13335"
$result->raw['asnOrganization']; // "Cloudflare, Inc."
$result->raw['isProxy']; // false