1 /**
2 * 根據使用者IP擷取使用者地理位置
3 * $ip 使用者ip
4 */
5 function get_position($ip){
6 if(empty($ip)){
7 return '缺少使用者ip';
8 }
9 $url = 'http://ip.taobao.com/service/getIpInfo.php?ip='.$ip;
10 $ipContent = file_get_contents($url);
11 $ipContent = json_decode($ipContent,true);
12 return $ipContent;
13 }