Location detecting techniques for IP addresses

前端 未结 9 1200
甜味超标
甜味超标 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:45

    You can map an IP address to its location (city, country, postal code), timezone etc. with either a database or an API (hosted database).

    Here's an example of using an API

    curl https://ipapi.co/city/ 
    > Mountain View
    
    curl https://ipapi.co/country/
    > US
    
    curl https://ipapi.co/timezone/
    > America/Los_Angeles 
    

    more here : Location from IP address

提交回复
热议问题