mallka / easygeo
geolite2城市/asn包装器,支持更新数据库文件
v1.0
2021-03-16 15:43 UTC
Requires
- maxmind-db/reader: ~1.0
- tronovav/geoip2-update: ^1.2
README
特性
- 更新IP数据库文件
- geolite城市&asn包装器,将返回包含城市&asn信息的数组。
更新IP数据库文件
从您的maxmind账户获取您的许可证密钥,然后运行以下代码
<?php
use mallka\easygeo\Geo;
\mallka\easygeo\Geo::update('Your key','/path/to/your_db_floder');
获取IP的额外信息
<?php
use mallka\easygeo\Geo;
$res = \mallka\easygeo\Geo::getInfo('113.110.215.242','./store/GeoLite2-City.mmdb','./store/GeoLite2-ASN.mmdb',$lang='zh-CN');
$res = json_encode($res);
/**
$res will display as bellow:
{
"city":"深圳市",
"continent":"亚洲",
"country":"中国",
"registered_country":"中国",
"province":"广东",
"country_code":"CN",
"province_code":"GD",
"location"":{
"accuracy_radius":5,
"latitude":22.5333,
"longitude":114.1333,
"time_zone":"Asia/Shanghai"
},
"autonomous_system_number""":"AS4134",
"organization"":"ASChinanet"
}
**/
如何安装
通过composer
composer require mallka/easygeo
直接下载
- 下载文件(包括文件)
- 在Linux上,将存储文件夹的权限设置为777,例如chmod -Rf 777 store
- 从test.php使用它或学习它
谢谢
- tronovav/geoip2-update
- maxmind-db/reader