如何检测访客的国家/地区?

2022-01-14 00:00:00 location geolocation php javascript

可能重复:
IP地址的位置检测技术

对于我们的网站,重要的是要准确了解我们的访问者来自哪个国家/地区.

For our website it's important to know from exactly which country our visitor is coming from.

我想我的问题的最佳答案是当前浏览器系统的简单地理位置功能,它只是询问用户是否允许网站查看他的地理位置:http://dev.w3.org/geo/api/spec-source.html

I guess the best answer for my question would be the simple geo location feature of current browser systems, which just ask the user if the website is allowed to see his geographic location: http://dev.w3.org/geo/api/spec-source.html

但我不想用问题打扰访问者,我很想自动检测访问者的位置(国家应该足够了.)

but I don't want to bother visitor with questions, I would love to automatically detects the visitor's location (country should be enough.)

最好的方法是什么?- 什么 ip 数据库是最好的?- 浏览器标头是否足以检测到他的国家?(en-us en-en-ca?)最好的解决方案是什么?

What's the best way to do this? - what ip database would be the best? - is the browser header trustable enough to detect his country? (en-us en-en en-ca?) What's the best solution?

推荐答案

NetImpact 提供免费的 API通过 IP 进行地理定位查找,ProgrammableWeb 也有一个 综述 GeoIP 查找提供程序.这会在您的应用程序完成 API 调用时产生少量延迟(除非您的应用程序可以使用非阻塞调用),但这是检测访问者原籍国侵入性最小的方式.

NetImpact provide a free API for geolocation lookup by IP, ProgrammableWeb also has a roundup of GeoIP lookup providers. This involves a small amount of latency while your application completes an API call (unless your application can use a non-blocking call) but is the least intrusive manner of detecting a visitor's country of origin.

相关文章