以PHP Script查詢 IP 地址對應之相關資訊(國家、城市、ISP、Domain Name等) |
October 17, 2009 10:14PM 發表文章數: 1,006 |
[PHP]
$country = file_get_contents('http://api.hostip.info/country.php?ip='.$_SERVER['REMOTE_ADDR'];
echo $country;
[/PHP]
$ip = '59.32.28.65';
$url = "http://www.ipmango.com/api.php?ip=".$ip;
$xml = simplexml_load_file($url);
echo "IP address : {$xml->ipaddress} \n";
echo "City : {$xml->city} \n";
echo "Region : {$xml->region} \n";
echo "Country Name : {$xml->countryname} \n";
echo "Latitude : {$xml->latitude} \n";
echo "Longitude : {$xml->longitude} \n";