CalderaWP/location

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

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Ip to GeoIP Utility

Turns an IP address into GeoIP data.

Requires PHP7

Install

composer require calderawp/location

Usage

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;
        }
    }
Copyright 2016 CalderaWP LLC & Josh Pollock. Licensed under the terms of the GNU GPL version 2 or later. Please share with your neighbor.

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.