Get user city /state/ country information from IP Address

03 January 2014 — Written by Mitesh Patel
#ip#address#geoio

Get user city /state/ country information from IP Address.

<?php
function getInfo_of_ip($ip){
$url = "http://api.geoio.com/q.php?key=fC3tzSLwbhXWXnTS&qt=geoip&d=comma&q=".$ip;
$timeout = 5;
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
$d = curl_exec($ch);
curl_close($ch);
$data = explode(',' , $d);
return $data;
}
$info = getInfo_of_ip(192.168.1.54);
view raw foo.php hosted with ❤ by GitHub

Copyright © 2021 Mitesh Patel. Built with Gatsby