kruegge82/dhl-php-rest-sdk

注意:这是DPDHL集团包裹德国邮递API的规范。此REST Web服务允许商业客户按需创建运货标签。

v2.1.10.1 2024-08-29 07:55 UTC

This package is auto-updated.

Last update: 2024-09-29 09:09:45 UTC


README

注意:这是DPDHL集团包裹德国邮递API的规范。此REST Web服务允许商业客户按需创建运货标签。

安装与使用

要求

PHP 7.4及更高版本。也应在PHP 8.0中正常工作。

Composer

要通过Composer安装绑定,请将以下内容添加到composer.json

{
  "repositories": [
    {
      "type": "vcs",
      "url": "https://github.com/kruegge82/dhl-php-rest-sdk.git"
    }
  ],
  "require": {
    "kruegge82/dhl-php-rest-sdk": "*@dev"
  }
}

然后运行composer install

手动安装

下载文件并包含autoload.php

<?php
require_once('/path/to/OpenAPIClient-php/vendor/autoload.php');

入门

请遵循安装过程,然后运行以下命令

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




$apiInstance = new kruegge82\DHL\Api\GeneralApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client(['http_errors'=>false])
);

try {
    $result = $apiInstance->rootGet();
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling GeneralApi->rootGet: ', $e->getMessage(), PHP_EOL;
}

API端点

所有URI均相对于https://api-eu.dhl.com/parcel/de/shipping/v2

模型

Authorization

API定义的认证方案

BasicAuth

  • 类型:HTTP基本认证

ApiKey

  • 类型:API密钥
  • API密钥参数名称:dhl-api-key
  • 位置:HTTP头

测试

要运行测试,使用

composer install
vendor/bin/phpunit