개발자의 끄적끄적

[php/codeigniter] geoip library [펌] 본문

개발/php

[php/codeigniter] geoip library [펌]

효벨 2020. 6. 23. 02:00
728x90
반응형

[php/codeigniter] geoip library [펌]

 

 

잘정리되어 있는 geoip 라이브러리가 있어서

 

참고용으로 퍼왔습니다!!

 

개발하실때 참고들 하세요!!

 

출처는 아래 명시했습니다!

 

 

Geolocalization IP Online


Geolocalizacion mediante ip, utilizando la api de http://www.ipinfodb.com/, de manera online, sin base de datos locales. Sencilla libreria para el framework de php Codeigniter 3.0.

Simple library for CodeIgniter framework 3.0 to locate ip by online without locals database, http://www.ipinfodb.com/ APIs.

 

 

##Instructions:

 

1
Primero debes crearte una cuenta gratis en http://www.ipinfodb.com/ y obtener una clave y cambiar el valor de $_key en la clase (application/libraries/Geoip), puedes usar una clave que he generado yo por ti, pero no aseguro que funcione siempre.

 

You must first create an free account in http://www.ipinfodb.com/ and obtain a key and change the value of $_key in the class (application/libraries/Geoip), you can use a key generated by me, but I not assure that work for ever.

 

2
Debes agregar el archivo GeoIP.php en la carpeta application/libraries

You most add the file GeoIP.php in the folder application/libraries

 

3
Load the library, in your controller, model...

$this->load->library('geoip');

 

4
LLame al metodo geolocalization e ingresa una IP o nada, en su defecto se carga: $this->CI->input->ip_address()

Call method geolocalization and enter an IP Address or null,default load: $this->CI->input->ip_address()

$this->geoip->geolocalization("181.110.XXX.XXX");

 

5 Done!
Una vez cargado puedes obtener los detalles de geo localizacion del usuario mediante su IP.

Once loaded you can get user's geo location details by IP address.

echo $this->geoip->info->countryName; //return Argentina
echo $this->geoip->info->cityName; //return Buenos Aires
RETURNED DATA JSON OBJECT

{
    "statusCode" : "OK",
    "statusMessage" : "",
    "ipAddress" : "181.110.XXX.XXX",
    "countryCode" : "AR",
    "countryName" : "Argentina",
    "regionName" : "Distrito Federal",
    "cityName" : "Buenos Aires",
    "zipCode" : "1871",
    "latitude" : "35.6552",
    "longitude" : "-31.57*2",
    "timeZone" : "-03:00"
}

 

No es muy recomendable utilizar la api si se necesita una buena performance ya que es lenta, preferentemente llamar al metodo geolocalization a lo ultimo.

 

It is highly recommended to use the api if you want a good performance, preferably use the method geolocalization at last.

 

Desarrollado por: Ariel Marti

 

 

출처 : https://github.com/4riel/Geoip-codeigniter

반응형
Comments