1. Go to this page and download the library: Download davidepastore/ipinfo 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/ */
davidepastore / ipinfo example snippets
$ipInfo = new DavidePastore\Ipinfo\Ipinfo(array(
"token" => "your_api_key"
));
//Get all the properties
$host = $ipInfo->getFullIpDetails("8.8.8.8");
//Get only a single property (this could save bandwidth)
$city = $ipInfo->getSpecificField("8.8.8.8", DavidePastore\Ipinfo\Ipinfo::CITY);
//Get all the properties
$host = $ipInfo->getYourOwnIpDetails();
//Get only a single property (this could save bandwidth)
$city = $ipInfo->getYourOwnIpSpecificField(DavidePastore\Ipinfo\Ipinfo::CITY);
//Read all the properties
$city = $host->getCity();
$country = $host->getCountry();
$hostname = $host->getHostname();
$ip = $host->getIp();
$loc = $host->getLoc();
$org = $host->getOrg();
$phone = $host->getPhone();
$postal = $host->getPostal();
$region = $host->getRegion();
//Get the associative array with all the properties
$properties = $host->getProperties();
IpInfo::IP; //For the ip address
IpInfo::HOSTNAME; //For the hostname
IpInfo::LOC; //For the loc
IpInfo::ORG; //For the org
IpInfo::CITY; //For the city
IpInfo::REGION; //For the region
IpInfo::COUNTRY; //For the country
IpInfo::PHONE; //For the phone
IpInfo::POSTAL; //For the postal
IpInfo::GEO; //For the geo info. See the paragraph below for more info
IpInfo::IP; //For the ip address
IpInfo::CITY; //For the city
IpInfo::REGION; //For the region
IpInfo::COUNTRY; //For the country
IpInfo::PHONE; //For the phone
IpInfo::POSTAL; //For the postal
IpInfo::HOSTNAME; //For the hostname
IpInfo::LOC; //For the loc
IpInfo::ORG; //For the org