Simpliest way to get user's location using their IP address.
The application takes an IP address as input and retrieves information such as country, city, region, ISP name (org), geolocation (latitude,longitude), postal code, timezone, response_time etc. This project demonstrate to do so using PHP. But you can implement in any language by using curl .
How to use :
Clone the repository
git clone https://github.com/partho5/ip-location.git
- Open
index.php
file. There you replace the sample IP with your IP address for which you want to find location. - You need to get an API key from https://api.iplocation.net . It's free, though they have paid features. Anyway simply signup and you will get an API key. No card information required as of the time of writing this instruction (August 14, 2023).
Create a file named config.php
and write :
<?php
define('IPINFO_API_KEY', 'API KEY obtained from api.iplocation.net');
Now host the project in your server or localhost. Visit index.php file.
Sample output I got :