public function city($ip)
{
//每个ip的访问接口频率每分钟不能超过150次否者会被拉黑
if ($ip != '127.0.0.1'&& $ip !='localhost') {
$getip = file_get_contents("http://ip-api.com/php/" . $ip . '?lang=zh-CN');
$getarr = unserialize($getip);
if($getarr['status']=="success"){
//拼接country 国家 regionName 省 city 市
return $getarr['country'] . $getarr['regionName'] . $getarr['city'];
}else{
return '获取失败';
}
} else {
return '未知ip';
}
}
最后修改:2020 年 07 月 19 日 12 : 14 AM
© 允许规范转载
5 条评论
Hello?what is up?
啥玩意
非技术的路过。
这个我记得是有调用次数限制的吧OωO
有