2017 © Pedro Peláez
 

library dhl-api-wrapper

Dhl Api Wrapper

image

dhl-plugins/dhl-api-wrapper

Dhl Api Wrapper

  • Wednesday, June 27, 2018
  • by DhlPlugins
  • Repository
  • 3 Watchers
  • 4 Stars
  • 194 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 2 Versions
  • 137 % Grown

The README.md

Dhl-api-wrapper (Deprecated, please read our warning)

WARNING

Provided as-is, but deprecated and no longer supported., (*1)

Installing via Composer

The recommended way to install the wrapper is through Composer., (*2)

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

Next, run the Composer command to install the latest stable version of the wrapper:, (*3)

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

After installing, you need to require Composer's autoloader:, (*4)

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

Frequently asked questions

See FAQ.md., (*5)

Getting Started

First you will need to initialise the client like this:, (*6)

$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., (*7)

More complete examples are located in the examples directory, (*8)

Create Shipping Label

check the create label example for the $parameters variable., (*9)

// 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., (*10)

Bugs & Issues

We no longer maintain this wrapper., (*11)

The Versions