zmog/ipstacker

此包最新版本(0.0.3)没有可用的许可证信息。

IP栈API调用包装器

0.0.3 2021-05-19 16:12 UTC

This package is auto-updated.

Last update: 2024-09-19 23:35:46 UTC


README

IP栈API调用包装器

使用示例

基本用法

$Response = (new \Zmog\Libs\IpStacker\Request('<your_access_key>', '<ip_address>'))->Response();

$country_code = $Response->country_code(); /* Throw an exception if country_code is not present in response */
$country_code = $Response->country_code('US'); /* Use 'US' as default value if country_code is not present in response (no exception are thrown */

高级用法

$ip_a = [
    '8.8.8.8',
    '1.1.1.1',
    ];

$Request = new \Zmog\Libs\IpStacker\Request('<your_access_key>', ...$ip_a);
$Request->onlyLocation();
$Request->addCurrency();
/* Or chained method
$Request = (new \Zmog\Libs\IpStacker\Request('<your_access_key>', ...$ip_a))->onlyLocation()->addCurrency();
*/

/* Result of first ip : */
$is_eu_8dot = $Request->Response('8.8.8.8')->location()->is_eu(false);
/* or 
$is_eu_8dot = $Request->Response()->location()->is_eu(false);
*/

/* Result of second ip */ 
$is_eu_1dot = $Request->Response('1.1.1.1')->location()->is_eu(false);