-3

我试图提取有关访问者 IP 地址的正确信息:

ISP
Organization    
City
Region
Country

我可以通过 json_decode 和 file_get_contents 提取这些信息:

$ip = $_SERVER['REMOTE_ADDR'];
$details = json_decode(file_get_contents("http://ipinfo.io/{$ip}")); // or from whatismyipaddress.com
echo $details->city; 

我也可以自己写代码(geoip)

但这不是提取此信息的正确方法(通过使用 curl),
并且唯一返回正确信息的网站是http://whatismyipaddress.com/

我尝试使用 geoip 但我的 php 返回不正确的信息。

4

1 回答 1

1

你做不到,这是不可能的。您提到的这个网站(whatismyipaddress.com)有一些大型数据库,其中包含所有 IP 范围以及绑定到它们的信息。但这对每个人来说都不是真的准确——你只是幸运(或不幸运)。

于 2013-10-18T02:12:04.423 回答