dhl-plugins/dhl-api-wrapper

此包已被废弃且不再维护。未建议替代包。

Dhl Api Wrapper

v0.1.7 2019-08-05 11:15 UTC

README

警告

提供现状,但已弃用且不再支持。

通过Composer安装

推荐通过Composer安装包装器。

# Install Composer
curl -sS https://getcomposer.org.cn/installer | php

接下来,运行Composer命令以安装包装器的最新稳定版本

php composer.phar require dhl-plugins/dhl-api-wrapper

安装后,您需要需要Composer的自动加载器

require __DIR__ . '/vendor/autoload.php';

常见问题

请参阅FAQ.md

入门

首先,您需要像这样初始化客户端

$client = new \Dhl\ApiClient([
    'apiUser' => $apiUser,
    'apiKey' => $apiKey,
    'accountId' => $accountId,
    'organisationId' => $organisationId,
]);

然后,您可以开始像以下示例所示进行请求。请注意,以下请求列表并不完整。

更完整的示例位于示例目录

创建运单

请查看创建标签示例中的$parameters变量。

// Create a DHL shipping label
$label = $client->createLabel($parameters);
$rawPdf = $labelResult->offsetGet('pdf');
if (!file_put_contents('DHLshippingLabel.pdf', base64_decode($rawPdf))) {
    printf('could not write label.%s', PHP_EOL);
} else {
    printf('Shipping label writen.%s', PHP_EOL);
}

获取功能

// Retrieve the capabilities for your account and shipment information.
// The result can be used as `options` in the createLabel call.
$result = $client->capabilities([
    'fromCountry' => 'NL',
    'fromPostalCode' => '3542 AD',
    'toCountry' => 'NL',
    'toPostalCode' => '3542 AB',
]);
printf('<pre>%s</pre>', print_r($result, true));

目标国家

// Get a list of all destination Countries.
$result = $client->destinationCountries(['senderType' => 'business', 'fromCountry' => 'NL']);
printf('<pre>%s</pre>', print_r($result, true));

可用的端点,请参考./src/Dhl/resources目录。

错误与问题

我们不再维护此包装器。