how can I retrieve the region and the city from an ip? I have found this service: http://api.hostip.info/?ip=xyz.qwe.rty
But It doesn't give me accurate info like this: http://www.ipaddresslocation.org/
Do you know some free service? I need to retrieve this info with a php script, but I wouldn't install external library.
Thank you so much
To reiterate, however, an IP address isn't enough. You need to use a geolocation database to obtain this user information. The most basic information provided in most geolocation databases includes the continent, country, state/region, city, and time zone of the electronic device.
ISP improvements and growthISPs update their databases for accuracy, and this can cause IP addresses to change. Take, for instance, this geolocation change we recently noticed. The geolocation update is most likely due to improvements and updates in ISPs databases.
No you can't - IP addresses get reallocated and reassigned from time to time, so the mapping of IP to location will also change over time. GeiLite seems legit. I didn't know there are so many geonames. Takes a bit of time to insert into the database parsed.
http://ipinfo.io, my service, gives you city, country and other related information about an IP:
$ curl ipinfo.io/8.8.8.8 { "ip": "8.8.8.8", "hostname": "google-public-dns-a.google.com", "loc": "37.385999999999996,-122.0838", "org": "AS15169 Google Inc.", "city": "Mountain View", "region": "CA", "country": "US", "phone": 650 }
Here's a PHP example:
$details = json_decode(file_get_contents("http://ipinfo.io/".$_SERVER['REMOTE_ADDR']")); echo $details->city; // -> "Mountain View"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With