How can I determine the IP address location? For example, if a Shanghai user logs on to our website, the domain name automatically jumps to Shanghai, such as the question, one website has two domain names, the primary domain name and the Shanghai domain name, how can a user in Shanghai automatically jump to the domain name in Shanghai by checking whether the user is located in Shanghai when using the primary domain name for access.
Reply to discussion (solution)
Use taobao APIs
Function Get_Ip_From ($ ip = '') {if (empty ($ ip) {$ ip = self: Getip () ;}$ ip_json = @ file_get_contents (" http://ip.taobao.com/service/getIpInfo.php? Ip = ". $ ip); $ ip_arr = json_decode (stripslashes ($ ip_json), 1); if ($ ip_arr ['code'] = 0) {return $ ip_arr ['data'];} else {return false ;}}
There are many ip address libraries. Pure. Baidu. Sina. For google, you can configure ini or write data in the code.