因为百度ip转换增加了密匙验证,所以导致之前的接口无法再转换ip地址的信息,修复方法如下:
打开include\cloud.func.php文件
搜索:
function iplookup($ip) {
$url = ‘http://apistore.baidu.com/microservice/iplookup?ip=’.$ip;
$rec = dcurl($url);
$area = ”;
if(strpos($rec, ‘retData’) !== false) {
$tmp = json_decode($rec, true);
$arr = $tmp[‘retData’];
if(base64_encode($arr[‘country’]) != ‘5Lit5Zu9’) {
if(isset($arr[‘country’])) $area .= $arr[‘country’];
if(isset($arr[‘area’])) $area .= $arr[‘area’];
}
if(isset($arr[‘province’])) $area .= $arr[‘province’];
if(isset($arr[‘city’]) && $arr[‘city’] != $arr[‘province’]) $area .= $arr[‘city’];
if(isset($arr[‘district’])) $area .= $arr[‘district’];
if(isset($arr[‘carrier’])) $area .= ‘ ‘.$arr[‘carrier’];
}
return $area ? convert($area, ‘UTF-8’, DT_CHARSET) : ‘Unknown’;
}
复制代码
替换修改为:
function iplookup($ip) {
$url = ‘http://ip.taobao.com/service/getIpInfo.php?ip=’.$ip;
$rec = dcurl($url);
$area = ”;
if(strpos($rec, ‘data’) !== false) {
$tmp = json_decode($rec, true);
$arr = $tmp[‘data’];
if(base64_encode($arr[‘country’]) != ‘5Lit5Zu9’) {
if(isset($arr[‘country’])) $area .= $arr[‘country’];
if(isset($arr[‘area’])) $area .= $arr[‘area’];
}
if(isset($arr[‘region’])) $area .= $arr[‘region’];
if(isset($arr[‘city’]) && $arr[‘city’] != $arr[‘region’]) $area .= $arr[‘city’];
if(isset($arr[‘district’])) $area .= $arr[‘district’];
if(isset($arr[‘isp’])) $area .= ‘ ‘.$arr[‘isp’];
}
return $area ? convert($area, ‘UTF-8’, DT_CHARSET) : ‘Unknown’;
}