jayin / ipgeo
Get IP GEO
Installs: 6
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/jayin/ipgeo
Requires
- php: >=7.0
- guzzlehttp/guzzle: ^7.4
Requires (Dev)
- phpunit/phpunit: ^9.0
This package is auto-updated.
Last update: 2025-11-07 17:48:50 UTC
README
获取IP的地理位置信息(所属国家、省、市、区、经纬度)
支持地图:
- 腾讯地图 https://lbs.qq.com
- TODO 百度地图
- TODO CZ88 https://www.cz88.net/help?id=free
Install
$ composer require jayin/ipgeo -vvv
Usage
$ipGeo = new IpGeo(); $ipGeo->setConfig([ 'driver' => 'Tencent', 'drivers' => [ 'Tencent' => [ [ 'app_key' => '{app_key}', ] ], ] ]); $ip = '61.140.183.172'; $info = $ipGeo->geo($ip); // 指定配置 $info = $ipGeo->useDriver('baidu')->geo($ip)
返回格式如下
{
"driver": "Tencent",
"ip": "61.140.183.172",
"lat": 23.12908,
"lng": 113.26436,
"nation": "中国",
"province": "广东省",
"city": "广州市",
"district": ""
}
Test
$ composer run test
License
MIT