Identifying the country of visitor to my website

我的未来我决定 提交于 2019-12-09 06:57:11

问题


I want to identify the country my visitors come from using php. How can I do this?


回答1:


You need to use the PHP GeoIP extension that allows you to locate various information about the users via IP. http://us.php.net/geoip

or you can use Maxmind's API to access the data aswell. http://www.maxmind.com/app/php




回答2:


You need to use a Geolocation service/database. Check out the Maxmind API.




回答3:


I recommend you taking a look at the MaxMind's GeoIP API:

http://www.maxmind.com/app/php




回答4:


I realise this is an old question but just in case people are still looking at it, be aware that the accuracy of these utilities is not guaranteed and you should be cautious what you use them for, especially if you start using them for lower granularity than country level searches.

WhatIsMyIPAddress.com claim 95-99% for country level but suggest 50-80% for city level in the USA (see http://whatismyipaddress.com/geolocation-accuracy). My experience is that some countries have an even lower accuracy rate for city level locations.

Edited: Not sure what the vote down is for - if there is something incorrect here please let us know. I am not aware of any current IP to Geo location techniques that allow city level accuracy reliably.




回答5:


There is a complete project using the maximind API in PHP Where are you from? IP Geolocation




回答6:


You can find more details about How to find the city and country of the visitor using PHP in this blog - http://virallangaliya.blogspot.in/2013/04/how-to-find-city-and-country-of-visitor.html



来源:https://stackoverflow.com/questions/1180359/identifying-the-country-of-visitor-to-my-website

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!