ampahkwabena/ghanapostgps

用于连接 GhanaPostGPS 的 PHP 包

v0.1.0 2022-02-10 13:06 UTC

This package is not auto-updated.

Last update: 2024-09-21 01:32:06 UTC


README

GhanaPostGPS 的 PHP 包

此包连接 GhanaPostGPS 以查找加纳的数字地址。

安装

您可以通过 composer 使用以下命令安装此包:

composer require ampahkwabena/ghanapostgps

您需要什么

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

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

数据 API

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

$asaaseUser = 'ASAASE-USER-ID'
$deviceId = 'DEVICE-ID'
$aesKey = '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,或者通过 ampahkwabena5@gmail.com 邮件与我联系,以做出长期承诺。

许可

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