dhl-plugins/dhl-api-wrapper

This package is abandoned and no longer maintained. No replacement package was suggested.

Dhl Api Wrapper

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

README

WARNING

Provided as-is, but deprecated and no longer supported.

Installing via Composer

The recommended way to install the wrapper is through Composer.

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

Next, run the Composer command to install the latest stable version of the wrapper:

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

After installing, you need to require Composer's autoloader:

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

Frequently asked questions

See FAQ.md.

Getting Started

First you will need to initialise the client like this:

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

Then you can begin making requests like shown below. Please note that the list of requests below is not complete.

More complete examples are located in the examples directory

Create Shipping Label

check the create label example for the $parameters variable.

// 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 Capabilities

// 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));

Destination Countries

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

Endpoints which are available, take a look in the ./src/Dhl/resources directory for reference.

Bugs & Issues

We no longer maintain this wrapper.