Simple Tutorial Get Geolocation IP With PHP

To get Geo location (country, city, isp, etc.) based on website visitor IP in PHP application can use API from ip-api.com. In this article, I will share how to get geolocation information from site visitors using PHP.

IP-API is a free GEO LOCATION IP service with multiple response formats. In addition to free, its use is also quite easy to apply. However, free facilities have some limitations. IP-API server will automatically be banned IP Addresses if making more than 150 requests per minute. If you need more data from IP-API, you can buy a pro service.

Another article: Angular 4 Tutorial For Beginner With Simple App Project

Tutorial get GEOLOCATION IP Information with PHP

Make a function to get Ip visitors

Create a function to call the geolocation API from ip-api.com

Test both functions above using the following code

If successful you will get results like the following picture

Simple Tutorial Get Geolocation IP With PHP

Note: The above script does not work on the localhost server.

Conclusion:

To obtain information geolocation is very easy using API from ip-api.com. You can subscribe for €45 (3 months) for unlimited use of API

So my short tutorial on Simple Tutorial Get Geolocation IP With PHP, hopefully, useful

The following two tabs change content below.
This site is a personal Blog of Sigit Prasetya Nugroho, a Desktop developer and freelance web developer working in PHP, MySQL, WordPress.

Leave a Comment

Your email address will not be published.

Time limit is exhausted. Please reload CAPTCHA.