-3

i tried to extract correct information about the visitor ip address:

ISP
Organization    
City
Region
Country

i can extract this information by json_decode and file_get_contents:

$ip = $_SERVER['REMOTE_ADDR'];
$details = json_decode(file_get_contents("http://ipinfo.io/{$ip}")); // or from whatismyipaddress.com
echo $details->city; 

and i also can write the code by my own(geoip)

but this is not the right way to extract this information(by using curl),
and the only website that returns correct information is http://whatismyipaddress.com/

i tried to use geoip but my php returns incorrect information.

1 Answers1

1

You can't do it, it's impossible. This website you mention (whatismyipaddress.com) has some big database containing all the IP ranges with information bound to them. But it isn't really accurate for everyone neither - you're just lucky (or not).

Milosz
  • 511
  • 4
  • 5