chrisullyott/php-ip-api
Composer 安装命令:
composer require chrisullyott/php-ip-api
包简介
A PHP wrapper for ip-api.com.
README 文档
README
PHP IP API
Fetch geolocation data for IP addresses from ip-api.com.
Installation
$ composer require chrisullyott/php-ip-api
Instantiation
$api = new ChrisUllyott\IpApi(); // Set output language and fields (optional) $api->setLanguage('en'); $api->setFields(['query', 'country', 'city']);
Request one
$response = $api->get('91.198.174.192'); print_r($response);
stdClass Object
(
[country] => Netherlands
[city] => Amsterdam
[query] => 91.198.174.192
)
Request many
$ips = [ '100.142.29.254', '100.142.39.218' ]; $response = $api->get($ips); print_r($response);
Array
(
[0] => stdClass Object
(
[country] => United States
[city] => Chicago
[query] => 100.142.29.254
)
[1] => stdClass Object
(
[country] => United States
[city] => Chicago
[query] => 100.142.39.218
)
)
Request from a file (create CSV)
Using a newline-separated list of IP addresses, a CSV file of response data will be built.
$file = 'ips.txt'; $list = new ChrisUllyott\IpApiList($file); $list->setFields(['query', 'country', 'city']); $list->build();
统计信息
- 总下载量: 419
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-08-11