PHP code example of djonepl / ipapi-co-php
1. Go to this page and download the library: Download djonepl/ipapi-co-php 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/ */
djonepl / ipapi-co-php example snippets
use IpApi\IpApi;
$api = new IpApi('APIKEY');
$location = $api->lookup('IP');
$location = $api->lookup('8.8.8.8');
// Convert the object to an array
$data = $location->toArray();
// Extract city and ASN
echo $location->city; // Mountain View
echo $location->asn; // AS15169