根据IP查询所在地区
IpIp
官网:https://www.ipip.net/
IPv4免费地址库:https://www.ipip.net/product/client.html
Github:https://github.com/ipipdotnet
Java Demo:https://github.com/ipipdotnet/ipdb-java
PHP Demo:https://github.com/ipipdotnet/ipdb-php
public function setIp($ip)
{
if (!class_exists('IP')) {
include dirname(__FILE__) . "/../third_party/ipip/IP.class.php";
}
$loc = IP::find($ip);
if ($loc == 'N/A') {
return;
}
if (isset($loc[0]) && $loc[0] != '')
$this->country = $loc[0];
if (isset($loc[1]) && $loc[1] != '')
$this->region = $loc[1];
if (isset($loc[2]) && $loc[2] != '')
$this->city = $loc[2];
}
GeoIp
官网:https://dev.maxmind.com/zh-hans/geoip/
GeoLite:https://dev.maxmind.com/zh-hans/geoip/legacy/geolite/
GeoLite2:https://dev.maxmind.com/zh-hans/geoip/geoip2/geolite2/
Github:https://github.com/maxmind
Java Demo:https://github.com/maxmind/GeoIP2-java
PHP Demo:https://github.com/maxmind/GeoIP2-php
在线
版权声明:
作者:Joe.Ye
链接:https://www.appblog.cn/index.php/2023/03/04/query-location-based-on-ip/
来源:APP全栈技术分享
文章版权归作者所有,未经允许请勿转载。
共有 0 条评论