根据客户端IP去获取地区API接口
第一种淘宝IP接口
<?php $ip = $_SERVER['REMOTE_ADDR']; $url = 'http://ip.taobao.com/outGetIpInfo?ip=' . $ip . '&accessKey=alibaba-inc'; $ip_content = file_get_contents($url); $ip_content = json_decode($ip_content, true); echo json_encode($ip_content); ?>
第二种百度IP接口
<?php $ip = $_SERVER['REMOTE_ADDR']; $url = 'http://opendata.baidu.com/api.php?query=' . $ip . '&co=&resource_id=6006&oe=utf8'; $ip_content = file_get_contents($url); $ip_content = json_decode($ip_content, true); echo json_encode($ip_content); ?>