根据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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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

在线

IP.CN:https://ip.cn/index.php?ip=8.8.8.8

Powered by AppBlog.CN     浙ICP备14037229号

Copyright © 2012 - 2020 APP开发技术博客 All Rights Reserved.

访客数 : | 访问量 :