manzadey/sypexgeo

支持GeoIP服务

v0.1 2021-10-27 13:31 UTC

This package is auto-updated.

Last update: 2024-09-27 19:47:44 UTC


README

此包旨在通过服务数据库 https://sypexgeo.net 获取IP地址信息

安装

composer require "manzadey/sypexgeo"

如何使用

创建类的实例,并将文件路径和操作模式标志作为参数(可选)

use Manzadey\SypexGeo\SxGeo;

$sxGeo = new SxGeo('sxGeo.dat');

定义国家

$country = $sxGeo->getCountry($ip); // returns a two-digit ISO country code
$sxGeo->getCountryId($ip);          // returns the country number

定义城市

$sxGeo->getCity($ip);                 // returns brief information, without the name of the region, country and time zone
$sxGeo->getCityFull($ip);             // returns full information about the city, region and country
$city = $sxGeo->get($ip);             // executes getCountry or getCity depending on the type of database
$cityName = $sxGeo->getCityName($ip); // returns the name of the city