ismystore/checkip

一个使用 www.geoplugin.net 从 IP 地址获取信息的 composer 模块

1.0.2 2022-05-22 16:26 UTC

This package is auto-updated.

Last update: 2024-09-08 18:04:00 UTC


README

一个使用 geoplugin.net 从 IP 地址获取信息的 composer 模块

安装

使用 composer 安装 CheckIP

composer require ismystore/checkip

使用方法

<?php

use ismystore\checkip\CheckIP;

class MyAwesomeClass{
    public function getMyPlayer(Person $person){
        $ip = $person->getAddress();
        $check = new CheckIP($ip);
        
        $msg = "";
        $msg .= "Your country is: ".$check->getCountry()."\n";
        $msg .= "Your country code is: ".$check->getCountryCode()."\n";
        $msg .= "Your region code is: ".$check->getRegionCode()."\n";
        $msg .= "Your state/region name is: ".$check->getState()."\n";
        $msg .= "Your city is: ".$check->getCity()."\n";
        $msg .= "Your address is: ".$check->getAddress()."\n";
        $msg .= "Is a european country ? ".($check->getEuropean() ? "Yes" : "No")."\n";
        $msg .= "Your timezone is: ".$check->getTimezone()."\n";
        $msg .= "Your currency code is: ".$check->getCurrencyCode()." (".$check->getCurrencySymbol().")\n";
        $person->send($msg);
   }
}

测试

确保您位于模块的根目录下

php tests/test.php