【问题标题】:Extract correct information about ip address提取有关 ip 地址的正确信息
【发布时间】:2013-10-18 02:03:02
【问题描述】:

我试图提取有关访问者 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 返回的信息不正确。

【问题讨论】:

标签: php curl ip


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2012-02-08
    • 2011-09-30
    • 2012-09-30
    • 1970-01-01
    • 1970-01-01
    • 2018-09-19
    • 1970-01-01
    • 1970-01-01
    • 2013-11-01
    相关资源
    最近更新 更多