【发布时间】: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 返回的信息不正确。
【问题讨论】:
-
@EmilioGort 我询问了更多信息