获取IP的详情:
http://ip.taobao.com/service/getIpInfo.php?ip=(IP地址)
PHP获取方法:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | //返回ip所在的区域 外国ip精确到国名 function getcposition( $ip ){ try { $res1 = file_get_contents ( "http://ip.taobao.com/service/getIpInfo.php?ip=$ip" ); $res1 = json_decode( $res1 ,true); if ( $res1 [ "code" ]==0){ return $res1 [ 'data' ][ "country" ]. $res1 [ 'data' ][ "region" ]. $res1 [ 'data' ][ "city" ]. "_" . $res1 [ 'data' ][ "isp" ]; } else { return "未能获取" ; } } catch (Exception $e ){ return "未能获取" ; } } |
本文为dsg112社区原创文章,转载无需和我联系,但请注明来自dsg112社区. www.dsg112.com