The service IP Geolocation is free for the test and small applications and sites.
Development
Due to powerful and optimized servers located on different continents and productive database, achieve a real response of up to 90 milliseconds in most parts of the world.
PHP Library
Go to Github Project
PHP Function
$ip = "CLIENT_IP_ADDRESS";
$location = get_ipwhois($ip);
$decodedLocation = json_decode($location, true);
echo "<pre>";
print_r($decodedLocation);
echo "</pre>";
function get_ipwhois($ip, $format = "json", $lang = "en") {
$url = "http://free.ipwhois.io/".$format."/".$ip."?lang=".$lang;
$cURL = curl_init();
curl_setopt($cURL, CURLOPT_URL, $url);
curl_setopt($cURL, CURLOPT_HTTPGET, true);
curl_setopt($cURL, CURLOPT_RETURNTRANSFER, true);
curl_setopt($cURL, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Accept: application/json'
));
return curl_exec($cURL);
}
Top comments (1)
Great. Thanks for sharing.
geo.ipify.com also provides powerful IP Location Lookup API