Location detecting techniques for IP addresses

前端 未结 9 1202
甜味超标
甜味超标 2020-11-28 12:22

What are the location detecting techniques for IP addresses?
I know to look at the
$_SERVER[\'HTTP_ACCEPT_LANGUAGE\'] (not accurate but mostly useful to

9条回答
  •  我在风中等你
    2020-11-28 12:44

    Most of the existing databases use an aggregation of data from the international registries ARIN, AFRINIC, ANIC etc as well as user submitted locations. More sophisticated techniques include Topology and Constraints Geolocation.

    I run my own API ipdata.co that provides several data points including, the country, city, region, lat/long and others.

    This answer uses a 'test' API Key that is very limited and only meant for testing a few calls. Signup for your own Free API Key and get up to 1500 requests daily for development.

    php > $data = json_decode(file_get_contents('https://api.ipdata.co/69.59.196.211?api-key=test'),true);
    php > echo $data['country_name'];
    //United States
    php > echo $data['city'];
    //Albany
    

提交回复
热议问题