Giter VIP home page Giter VIP logo

codeigniter-geolocation's Introduction

CodeIgniter Geolocation Library

CodeIgniter Geolocation library allows you to locate an IP Address using "ipinfodb" API.

Installation

CodeIgniter Versoin >= 2.x.x

Copy the file config/geolocation.php to the application/config folder.

Copy the file libraries/geolocation.php to the application/libraries folder.

Usage

You need to subscribe to http://ipinfodb.com/register.php to get your API KEY and then,

Open application/config/geolocation.php and put it there :

$config['api_key'] = 'YOUR_API_KEY';

After that, you can call the library within your controller for instance like following :

$this->load->library('Geolocation');
$this->load->config('geolocation', true);

$config = $this->config->config['geolocation'];

$this->geolocation->initialize($config);
$this->geolocation->set_ip_address($ip); // IP to locate
// $this->geolocation->set_format('json');
// OR you can change the format within `config/geolocation.php` config file
$country = $this->geolocation->get_country();
var_dump($country);

// For more precision
$city = $this->geolocation->get_city();
if($city === FALSE)
    var_dump($this->geolocation->get_error());
else
    var_dump($city);

Additional parameters

You can change the result format within the config file, or leave it empty to return a PHP Array

Open application/config/geolocation.php :

$config['format'] = 'json'; // available format : xml|raw|json  or empty for php array

IpInfoDb API :

For more information about the API please visit : http://ipinfodb.com

codeigniter-geolocation's People

Contributors

jcsama avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.