Name: location
Owner: Caldera Labs
Description: Get GeoIP data via IP
Created: 2016-08-13 23:29:24.0
Updated: 2016-08-13 23:30:22.0
Pushed: 2016-08-13 23:32:15.0
Homepage: null
Size: 2
Language: PHP
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Turns an IP address into GeoIP data.
Requires PHP7
composer require calderawp/location
Find IP via http://freegeoip.net/ :
$geo = new FreeGEOIP( '1.2.3.5' );
$geo->query();
$location = $geo->get_location();
Free GEOIP is rate limitted, you can deploy your own instance. But then you will need to write your own handler class. Here is an example, assuming your API is at http://HiRoy.club/geo
:
class MyGeoIP extends GEOIP
{
/**
* @inheritdoc
*/
protected function apiRoot() : string
{
return 'http://HiRoy.club/geo/json/';
}
/**
* @inheritdoc
*/
protected function getApiUrl( string $ip ) : string
{
return $this->apiRoot() . $ip;
}
}