

If you need to get location from an IP address you can use reliable geo ip service, you can get more detail here. $ip_address = getenv('HTTP_CLIENT_IP') ?: getenv('HTTP_X_FORWARDED_FOR') ?: getenv('HTTP_X_FORWARDED') ?: getenv('HTTP_FORWARDED_FOR') ?: getenv('HTTP_FORWARDED') ?: getenv('REMOTE_ADDR') In PHP - returns location, timezone and date/time: // Get IP address It was created because I needed to know which timezone my users were in, where in the world and what time it currently is.

At timezoneapi.io you can request an IP address and get several objects in return (I've created the service). In case anyone stumbles upon this thread, here's another solution. People do not appreciate the notion that they are being tracked, so - my thoughts are - get it from your client directly and with their permission and expect a lot to balk at the notion. Also, proxies are the least of your worries when validating the IP that you think is the originator. That will get you - the address of the IP's registered owner, but - not your client's location - you must get that from them and also - you have to ask for it. LACNIC's returns a 503 and AfriNIC apparently has no such API. Who Is is (obviously) an ancient TCP protocol, however - the way it worked originally was by connection to port 43, which makes it problematic getting it routed through leased connections, through firewalls.etc.Īt this moment - most Who Is is done via RESTful HTTP and ARIN, RIPE and APNIC have RESTful services that work. The process is in flux, which is why the various services here work sometimes and don't at other times. There are currently five Regional Internet Registries with varying degrees of functionality that serve as the first point of contact with regard to IP ownership. However, I do not see an answer here, what I see is a lot of people showing what they came up with from having the same question. This question is protected, which I understand. Var h = document.getElementsByTagName('script') Var script = document.createElement('script') Var ip = document.getElementById('ipv4') Var longitude = document.getElementById('longitude') Var latitude = document.getElementById('latitude') Var postal = document.getElementById('postal') Var city = document.getElementById('city') Var state = document.getElementById('state') Var country = document.getElementById('country')
