
OBTENER PAIS VISITANTE POR IP EN PHP
Para saber desde que país y ciudad visitan nuesta página es usar el webservice http://www.geoplugin.net/json.gp y pasarle la ip del visitante como parámetro. En php sería:
$visitorData = file_get_contents('http://www.geoplugin.net/json.gp?ip='.$_SERVER['REMOTE_ADDR']);
Donde en la variable $visitorData se guardará un json con la siguiente información:
geoplugin_request "83.54.248.100"
geoplugin_status 200
geoplugin_delay "1ms"
geoplugin_credit "Some of the returned data includes GeoLite data created by MaxMind, available from http://www.maxmind.com."
geoplugin_city "Madrid"
geoplugin_region "Madrid"
geoplugin_regionCode "M"
geoplugin_regionName "Madrid"
geoplugin_areaCode ""
geoplugin_dmaCode ""
geoplugin_countryCode "ES"
geoplugin_countryName "Spain"
geoplugin_inEU 1
geoplugin_euVATrate 21
geoplugin_continentCode "EU"
geoplugin_continentName "Europe"
geoplugin_latitude "40.4097"
geoplugin_longitude "-3.7157"
geoplugin_locationAccuracyRadius "10"
geoplugin_timezone "Europe/Madrid"
geoplugin_currencyCode "EUR"
geoplugin_currencySymbol "?"
geoplugin_currencySymbol_UTF8 "?"
geoplugin_currencyConverter 0.832
Compartir en twitter