Tags
PHP
Asked 8 years ago
5 Oct 2016
Views 901
iptracker

iptracker posted

how to convert IP address to geographical location in php ?

How to convert IP address to geographical location in php ? or at least we can get city , region , country ?
shyam

shyam
answered Nov 30 '-1 00:00

use ipinfo.io api

$ipaddress="66.249.79.185";//google crawler IP address
$PinPointInfoFromIp=json_decode(file_get_contents("http://ipinfo.io/".$ipaddress));


following is json.
{
"ip": "66.249.79.185",
"hostname": "crawl-66-249-79-185.googlebot.com",
"city": "Mountain View",
"region": "California",
"country": "US",
"loc": "37.4192,-122.0574",
"org": "AS15169 Google Inc.",
"postal": "94043",
"carrier": "T-Mobile"
}
[/code]

you can use object to get info.for example $PinPointInfoFromIp->hostname give you hostname
Post Answer