2017 © Pedro Peláez
 

library location

Get GeoIP data via IP

image

calderawp/location

Get GeoIP data via IP

  • Sunday, August 14, 2016
  • by Shelob9
  • Repository
  • 1 Watchers
  • 0 Stars
  • 10 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Ip to GeoIP Utility

Turns an IP address into GeoIP data., (*1)

Requires PHP7, (*2)

Install

composer require calderawp/location, (*3)

Usage

Find IP via http://freegeoip.net/ :, (*4)

        $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 :, (*5)

        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;
            }
        }

The Versions

14/08 2016

dev-master

9999999-dev

Get GeoIP data via IP

  Sources   Download

GPLv2+

The Requires