php 根据ip获取地址
js方法获取用户的 ip 和 地址
获取用户的来源:$_SERVER[‘HTTP_REFERER’]
获取用户的 IP:$ip = $_SERVER[“REMOTE_ADDR”];
获取用户的地址:
1 > 使用淘宝API接口
function getCity(KaTeX parse error: Expected '}', got 'EOF' at end of input: ip = '') { if(ip == ‘’){
$url = “http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=json”;
i p = j s o n d e c o d e ( f i l e g e t c o n t e n t s ( ip=json_decode(file_get_contents( ip=jsondecode(filegetcontents(url),true);
$data = $ip;
}else{
u r l = " h t t p : / / i p . t a o b a o . c o m / s e r v i c e / g e t I p I n f o . p h p ? i p = " . url="http://ip.taobao.com/service/getIpInfo.php?ip=". url="http://ip.taobao.com/service/getIpInfo.php?ip=".ip;
i p = j s o n d e c o d e ( f i l e g e t c o n t e n t s ( ip=json_decode(file_get_contents( ip=jsondecode(filegetcontents(url));
if((string)$ip->code==‘1’){
return false;
}
d a t a = ( a r r a y ) data = (array) data=(array)ip->data;
}
return $data;
}