brightantwiboasiako/ghanapostgps

GhanaPostGPS 的 PHP 包

v0.0.5 2022-02-11 05:26 UTC

README

GhanaPostGPS 的 PHP 包

此包通过 GhanaPostGPS 查找加纳的数字地址。

安装

您可以通过 composer 安装此包

composer require omnilesolutions/ghanapostgps

所需条件

在连接到 GhanaPostGPS 之前,您需要以下内容

  1. AsaaseUser ID 这是在与 GhanaPostGPS 团队进行入职时给出的,您可以在 GPSAdmin Portal 的个人资料下找到
  2. DeviceID 您需要在 GPSAdmin Portal 上创建一个设备并使用该 ID。请注意,您可以在门户上创建多个设备。
  3. AES Key GhanaPostGPS 服务器使用 AES 加密与客户端进行通信。您可以在门户中为每个创建的设备访问您的 AES 密钥。

数据 API

使用 GhanaPostGPS\GhanaPostGPS 对象来获取数据。

$asaaseUser = 'YOUR-ASAASE-USER-ID'
$deviceId = 'YOUR-DEVICE-ID'
$aesKey = 'YOUR-AES-KEY-FOR-DEVICE'

$gps = new GhanaPostGPS\GhanaPostGPS($asaaseUser, $deviceId, $aesKey);

获取 GPS 名称(加纳代码)的位置

// Ghana Code
$gpsName = 'GA-585-7449';
 
// Location contains center latitude and longitude as well as
// a box around the center. You also get postcode, region,
// area, street, etc.
$location = $gps->getLocation($gpsName);

获取位置对应的 GPS 名称(加纳代码)

$location = [
    'lat' => 5.7525573723,
    'lng' => -2.873287368
];

// The GPS info contains postcode, region, area and street info
// for the provided location.
$gpsInfo = $gps->getGps($location);

测试

测试被设置为实际连接到 GhanaPostGPS 以确保一切正常。

要运行测试,请在 tests/Unit/GhanaPostGPSTest 中提供您的凭据并运行 vendor/bin/phpunit

先决条件

贡献

欢迎贡献!请提交任何错误修复的 PR,或者通过 brightantwiboasiako@aol.com 邮件与我联系,以进行长期承诺。

许可证

此开源项目受 MIT 许可证 的许可。