区分英国和美国的访客

时间:2011-09-20 12:07:33

标签: browser

显然,$ _SERVER [“HTTP_ACCEPT_LANGUAGE”]可以等于'en-us','en','us'或'en-gb'。问题:这个变量是了解访问者是美国还是英国的可靠方式?

(我不需要100%的可靠性,但至少要说70%)

2 个答案:

答案 0 :(得分:0)

您可以尝试将网络服务用于IP到国家/地区类型的地理位置。试试这个:http://www.hostip.info/use.html

使用示例:http://api.hostip.info/?ip=12.215.42.19

答案 1 :(得分:0)

通过IP: http://www.geoplugin.com/

如果您有一个包含国家/地区和纬度/经度信息的数据库,请访问Webbrowser:

if (navigator.geolocation)
    navigator.geolocation.getCurrentPosition(getGPSLocation);

function getGPSLocation(location) {
    locationGPS=location;
    alert('location \n'+
            'latitude:'+location.coords.latitude+'\n'+
            'longitude:'+location.coords.longitude+'\n'+
            'acurracy:'+location.coords.accuracy);
}
相关问题