eabay/yer

此包已被废弃,不再维护。未建议替代包。

PHP 地理位置库

dev-master 2012-08-07 13:57 UTC

This package is not auto-updated.

Last update: 2020-01-24 14:58:55 UTC


README

Yer 是一个 PHP 地理位置 库。

用法

通过 composer 安装 eabay/yer

定位提供者

Geobytes

<?php
require_once __DIR__.'/vendor/autoload.php';

$geolocation = new Yer\Geolocation;
$geolocation->setLocator(new Yer\Locator\GeobytesLocator());

var_dump($geolocation->lookup('193.140.215.133'));

您可以开启/关闭 ssl

<?php
...
$geolocation->setLocator(new Yer\Locator\GeobytesLocator(true));

如果您有付费订阅,

<?php
...
$geolocation->setLocator(new Yer\Locator\GeobytesLocator(true /* or false */, 'your email', 'your password'));

MaxMind

<?php
...
$geolocation->setLocator(new Yer\Locator\MaxMindWebServiceLocator('your license key'));

您可以通过实现 Yer\Locator\LocatorInterface 使用自定义定位提供者。

IP 地址验证

在查询定位提供者之前,您可以验证 IP 地址

<?php
...
$geolocation->setIpValidator(new Yer\Validator\IpValidator())

如果您想使用自己的验证器,实现 Yer\Validator\ValidatorInterface