Created
January 3, 2014 08:45
-
-
Save miteshmap/8234883 to your computer and use it in GitHub Desktop.
Get user city /state/ country information from IP Address.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment