kerekit/gls-parcelshops-cee

查询CEE国家(中东欧)的GLS快递商店

v1.0.4 2022-06-11 23:36 UTC

This package is auto-updated.

Last update: 2024-09-12 05:01:28 UTC


README

此软件包可以检索位于中东欧(CEE)地区GLS(通用物流系统)快递商店的信息,具体包括

  • CZ(捷克共和国)
  • HR(克罗地亚)
  • HU(匈牙利)
  • RO(罗马尼亚)
  • SI(斯洛文尼亚)
  • SK(斯洛伐克)

尽管GLS.dk上有支持多个国家查询快递商店的[SOAP Web服务][1],但对于上述国家它返回的是空列表。[GLS荷兰API][2]需要认证,并且似乎只发布荷兰的快递商店。

这让我们不得不研究[本地快递商店搜索的JavaScript][3],它了解该地区。所使用的Web服务未经文档记录,因此您可能预计它随时可能会消失或改变。在没有该地区的官方API之前,这是您的最佳选择。此软件包会尝试检测意外的行为,并在这种情况下抛出异常。

安装

composer require kerekit/gls-ee-parcelshops

使用

use Kerekit\GlsParcelshopsCee\{Parcelshop,CountryCode};

/**
 * List parcelshops in Hungary.
 *
 * NOTE: "ctrcode" is required, but you can use more filters (see
 * \Kerekit\GlsParcelshopsCee\Request\GetList properties), but results seem to
 * be inconsequent.
 */
$parcelshops = Parcelshop::list (['ctrcode' => CountryCode::HU ()]);

// Display some info about the first parcelshop.
$p = $parcelshops [0];
echo "The first shop's name is '$p->name'. You can call them on '$p->phone'.\n";

/**
 * Retrieve & display some opening hours for the first parcelshop.
 *
 * NOTE: Opening indexes range from 1 to 7 - Monday to Sunday!
 */
$openings = $p->getOpenings ();
$mon = $openings [1] ?? null;
if (!is_null ($mon)) {
    echo "Opening hours on Monday: $mon->open (lunch break: $mon->midbreak).\n";
}
$sun = $openings [7] ?? null;
if (!is_null ($sun)) {
    echo "Opening hours on Sunday: $sun->open (lunch break: $sun->midbreak).\n";
}

[1]: https://www.gls.dk/webservices_v4/wsShopFinder.asmx (GLS.dk Web服务)
[2]: https://api-portal.gls.nl/ (GLS荷兰API)
[3]: https://online.gls-hungary.com/psmap/psmap.js (匈牙利搜索脚本)