Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/JCSama/CodeIgniter-geolocation
CodeIgniter Geolocation library allows you to locate an IP Address using "ipinfodb" API.
https://github.com/JCSama/CodeIgniter-geolocation
Last synced: 3 days ago
JSON representation
CodeIgniter Geolocation library allows you to locate an IP Address using "ipinfodb" API.
- Host: GitHub
- URL: https://github.com/JCSama/CodeIgniter-geolocation
- Owner: JCSama
- License: mit
- Created: 2015-04-11T21:01:36.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-08-03T15:17:34.000Z (over 9 years ago)
- Last Synced: 2024-02-15T12:31:47.355Z (9 months ago)
- Language: PHP
- Homepage:
- Size: 170 KB
- Stars: 32
- Watchers: 4
- Forks: 18
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-codeigniter - CodeIgniter Geolocation - Library allows you to locate an IP Address. (Libraries)
README
# 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 :
```php
$config['api_key'] = 'YOUR_API_KEY';
```After that, you can call the library within your controller for instance like following :
```php
$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 ArrayOpen `application/config/geolocation.php` :
```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