[英]PHP Getting the location from an IP address MaxMind GEOIP
我正在使用PHP MaxMind GeoIP
来获取用户的位置。 我确实下载了两个文件进行测试: GeoLiteCity.dat
和GeoIPCity.dat
这是我的php
代码:
$ip = "189.90.207.67";
$gi = geoip_open("data/GeoLiteCity.dat", GEOIP_STANDARD);
$record = geoip_record_by_addr($gi, $ip);
print "Ip: ".$ip."<br>";
print "Country: ".$record->country_name . "<br>";
print "Region: ".$record->region. "<br>";
print "city: ".$record->city . "<br>";
print "latitude: ".$record->latitude . "<br>";
print "longitude: ".$record->longitude . "<br>";
geoip_close($gi);
结果:
IP:189.90.207.67国家:巴西地区:城市:纬度:-23.5477经度:-46.6358
返回的坐标不同于MaxMind: https://www.maxmind.com/en/geoip-demo ip: 189.90.207.67
我从ISP的代码中获得的坐标,与GeoIPCity.dat
不同,结果对于所有字段都是空的。
为什么网站和我的代码的结果不同?
在线演示正在使用商业数据库。 您的代码正在查询GeoLite数据库。
您不应期望从两个不同的数据库获得相同的结果。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.