Catch the user's city with IP [duplicate]

4

I need to get the city the user is at the moment of access to the Site Control Panel.

Why do I need this?

I want to block access to the control panel only for my client's city, when it does not have fixed , if it does, I block access only to its fixed IP.

I have already tested for GEOIP , but it gives me a very large distance, for example:

I put my IP and he showed me a city more than 50 km from where I am.

Does anyone know how to do this?

    
asked by anonymous 11.08.2015 / 21:02

2 answers

3

You can get information using the following XML:

link

You put the IP in place SEU_IP

or

link

Example:

http://api.ipinfodb.com/v3/ip-country/?key=<your_api_key>&ip=IP_AQUI

You put the IP in place IP_AQUI while your_api_key you put your key, to have this, you have to register on the site.

    
11.08.2015 / 21:15
2

Link: link

Documentation: link

Example:

{
  "status": "success",
  "country": "United States",
  "countryCode": "US",
  "region": "CA",
  "regionName": "California",
  "city": "San Francisco",
  "zip": "94105",
  "lat": "37.7898",
  "lon": "-122.3942",
  "timezone": "America/Los_Angeles",
  "isp": "Wikimedia Foundation",
  "org": "Wikimedia Foundation",
  "as": "AS14907 Wikimedia US network",
  "query": "208.80.152.201"
}
    
11.08.2015 / 22:41