fernleafsystems / apiwrappers-geoip
此软件包最新版本(2.0.0)没有提供许可信息。
2.0.0
2022-10-26 10:17 UTC
Requires
- php: 7.4
- ext-json: *
- fernleafsystems/apiwrappers-base: ^2.1
This package is auto-updated.
Last update: 2024-09-26 14:14:50 UTC
README
PHP 地理 IP/位置 API 包装器
安装
要开始使用,请通过以下命令将软件包添加到您的项目中
composer require fernleafsystems/apiwrappers-ipstack
Redirect.li - 入门
非常简单易用。与所有我们的 API 一样,您首先定义一个 API 连接,然后根据需要将其注入到各种 API 组件中。
在这种情况下
use FernleafSystems\ApiWrappers\GeoIP\Redirectli; $oConn = new Redirectli\Connection(); $oIpCountry = ( new Redirectli\Geo\Lookup() ) ->setConnection( $oConn ) ->me();
这将返回一个包含您 IP 所有信息的 IpGeoVO 对象。
GeoJS - 入门
非常简单易用。与所有我们的 API 一样,您首先定义一个 API 连接,然后根据需要将其注入到各种 API 组件中。
在这种情况下
use FernleafSystems\ApiWrappers\GeoIP\GeoJS; $oConn = new GeoJS\Connection(); $oIpCountry = ( new GeoJS\Country\Lookup() ) ->setConnection( $oConn ) ->me();
这将返回一个包含您 IP 所有国家信息的 IpCountryVO 对象。如果您需要更详细的信息,请使用 GeoJS\Geo\Lookup
而不是 GeoJS\Country\Lookup
。
您可以查找单个 IP 或多个 IP。在这种情况下,您将返回一个包含 VOs 的数组。
use FernleafSystems\ApiWrappers\GeoIP\GeoJS; $oConn = new GeoJS\Connection(); $oIpCountry = ( new GeoJS\Geo\Lookup() ) ->setConnection( $oConn ) ->ips( [ '1.1.1.1', '8.8.8.8' ] );
IPStack - 入门
非常简单易用。与所有我们的 API 一样,您首先定义一个 API 连接,然后根据需要将其注入到各种 API 组件中。
在这种情况下
use FernleafSystems\ApiWrappers\GeoIP\IPStack; $oConn = new IPStack\Connection(); $oConn->api_key = 'your_ipstack_api_key'; /** @var IPStack\IP\GeoIpVO $oIp */ $oIP = ( new IPStack\IP\Lookup() ) ->setConnection( $oConn ) ->ip( '123.123.123.123' );
在这种情况下,$oIP 将是一个包含该类所有属性的 GeoIpVO 对象。