Home API How to do an ip address lookup via extreme-ip-lookup.com in php

How to do an ip address lookup via extreme-ip-lookup.com in php

227
0

Very simple. Get all geolocation information about an IP address in JSON, JSONP and CSV format through our API. Free usage with max 20 requests per minute for backend requests. For use on a website the limit is 10,000 requests per month. Free usage includes HTTP and secure HTTPS requests!

1. Create a function to call the visitor’s ip
function visitor_ip(){
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
$ip = $_SERVER['HTTP_CLIENT_IP'];
}else if(!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
}else{
$ip = $_SERVER['REMOTE_ADDR'];
}
}

2. make API calls with curl
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"https://extreme-ip-lookup.com/json/".visitor_ip()."?key=Qn97RtiI2gwjStzJJjuG");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION,true);
curl_setopt($ch, CURLOPT_ENCODING, 'gzip, deflate');
$result = curl_exec($ch2);
$data_ip = json_decode($result,true);

3. You can display data
$isp = $data_ip['isp'];
$country = $data_ip['country'];
$countryID = $data_ip['country_code'];
$country = $data_ip['country'];
$region = $data_ip['region'];
$city = $data_ip['city'];

Here is a sample JSON Output from the server
{
"businessName" : "",
"businessWebsite" : "",
"city" : "Depok",
"continent" : "Asia",
"country" : "Indonesia",
"countryCode" : "ID",
"ipName" : "",
"ipType" : "Residential",
"isp" : "PT Telkom Indonesia",
"lat" : "-6.68917",
"lon" : "107.4",
"org" : "PT Telkom Indonesia",
"query" : "180.245.49.195",
"region" : "West Java",
"status" : "success",
"timezone" : "Asia/Jakarta",
"utcOffset" : "+07:00"
}

Now you have successfully created a fire lookup for free

Installer SSH & OpenVPN untuk VPS Debian 10 64 bit

Installing OpenVPN, OpenSSH, Dropbear, Squid SSH becomes easier and faster with the help of an installer script. You don't need Read more

Install Hostname SSL in DirectAdmin

DirectAdmin is a graphical web-based web hosting control panel that allows website administration via a web browser. The software can Read more

Previous articleLookup IP address with ipwhois.io in php
Next articleBUG Exploit at Amazon Affiliate WordPress Plugin (AAWP) 3.16

LEAVE A REPLY

Please enter your comment!
Please enter your name here