sen gent obv / chrono post-sdk
非官方 Chronopost API PHP SDK
1.0.0
2021-11-26 08:42 UTC
Requires
- php: ^7.4||^8.0
- ext-dom: *
- ext-json: *
- ext-mbstring: *
- ext-soap: *
- guzzlehttp/guzzle: ^7.0
- wsdltophp/packagebase: ~5.0
Requires (Dev)
- phpunit/phpunit: ^9.5
- vlucas/phpdotenv: ^5.1
This package is auto-updated.
Last update: 2024-09-26 15:14:07 UTC
README
非官方 Chronopost API PHP SDK
简单封装了 Chronopost SOAP API。
注意,目前这个库尚未经过充分测试,'接口'在此阶段不应被视为稳定。
如果您尝试了这个库并遇到问题或有一些建议,请在https://github.com/SengentoBV/chrono post-sdk/issues进行报告
安装 & 使用
需求
PHP 7.4 或更高版本。
请查看 composer.json 获取所有需求的列表。
Composer
推荐通过 Composer 安装这个库。
composer require sengentobv/chronopost-sdk
手动安装
下载文件并包含 autoload.php
<?php require_once('/path/to/chronopost-sdk/vendor/autoload.php');
入门指南
请按照安装流程进行,然后运行以下命令
<?php require_once(__DIR__ . '/vendor/autoload.php'); // Configure the authentication $authentication = new \SengentoBV\ChronopostSdk\ChronoAuthentication($ACCOUNT_NUMBER, $PASSWORD, $OPTIONAL_SUBACCOUNT); // Create an instance of the client $apiClient = new \SengentoBV\ChronopostSdk\ChronoApiClient($authentication); try { // Get an instance of the QuickSlot service $quickCostService = $apiClient->getQuickCostService(); // Perform a call that does not require authentication $result = $quickCostService->calculateDeliveryTime(new \SengentoBV\ChronopostSdk\Soap\QuickCostService\Structs\ChronoApiCalculateDeliveryTime(...)) print_r($result); // Perform a call that does require authentication // NOTE: You have to leave the username/password empty as the authentication information will be (over)written automatically! $result = $quickCostService->calculateProducts(new \SengentoBV\ChronopostSdk\Soap\QuickCostService\Structs\ChronoApiCalculateProducts(...)) print_r($result); } catch (\Exception $e) { echo $e->getMessage(); }
API 端点
以下 Web 服务已被封装/映射。
- https://ws.chronopost.fr/quickcost-cxf/QuickcostServiceWS
- https://ws.chronopost.fr/recherchebt-ws-cxf/PointRelaisServiceWS
- https://ws.chronopost.fr/rdv-cxf/services/CreneauServiceWS
- https://ws.chronopost.fr/shipping-cxf/ShippingServiceWS
- https://ws.chronopost.fr/tracking-cxf/TrackingServiceWS
授权
Chronopost 使用多种不同的方法进行认证(使用相同的凭证集)。
这个库旨在帮助您完成这一过程!
每次您创建一个新的请求对象时,您可以(应该)留空用于认证的字段,因为这个库将自动填充(或覆盖)这些字段。
测试
要运行测试,请使用
composer install vendor/bin/phpunit