How to determine the IP address location? For example, Shanghai user login to our website automatically jump to the domain name in Shanghai
Title, a website two domain name, the main domain name and the Shanghai domain name, how can realize the Shanghai user to use the main domain name to visit by the judge whether the user seat is in Shanghai and automatically jumps to the domain name of Shanghai.
------Solution--------------------
Using the Taobao API
function Get_ip_from ($ip = ") {
if (empty ($ip)) {
$ip = Self::getip ();
}
[Email protected]_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;
}
}
------Solution--------------------
There are many IP libraries. Pure. Baidu Sina. Google, as for the jump can be INI configuration, can also be written in code.