A Simple Package for IP to Location implementation with PHP using real-time API service through https://ipstack.com.
https://ipstack.com provides a public HTTP API for software developers to search the geolocation of IP addresses. It uses a database of IP addresses that are associated to cities along with other relevant information like time zone, latitude and longitude.
You're allowed up to 10,000 queries per month by default. Once this limit is reached, all of your requests will result in HTTP 403, forbidden, until your quota is cleared.
The ipstack is an API service which enable you to locate and identify website visitors at a stage before any data is entered into your system. The data received from the API can be used to enhance user experiences based on location data and assess risks and potential threats to your web application in time.
You can install the package via composer: Composer.
composer require sudiptpa/ipstack
And run composer to update your dependencies:
$ curl -s http://getcomposer.org/installer | php
$ php composer.phar update
This package only supports json
format for now.
Here are a few examples on how you can use the package:
$ipstack = new Sujip\Ipstack\Ipstack($ip);
$ipstack->country();
$ipstack->city();
$ipstack->region();
$ipstack = new Sujip\Ipstack\Ipstack($ip, $api_key);
$ipstack->formatted();
If you have a paid membership with https://ipstack.com and want to make API call with HTTPS mode, you can call ->secure() method.
$ipstack = (new Sujip\Ipstack\Ipstack($ip, $api_key))->secure();
$ipstack->formatted();
Also have a look in the source code of Sujip\Ipstack\Ipstack
to discover the methods you can use.
Please see CHANGELOG for more information what has changed recently.
Contributions are welcome and will be fully credited.
Contributions can be made via a Pull Request on Github.
$ composer test
If you are having general issues with the package, feel free to drop me and email [email protected]
If you believe you have found a bug, please report it using the GitHub issue tracker, or better yet, fork the library and submit a pull request.