dhl-plugins / dhl-api-wrapper
Dhl Api Wrapper
Installs: 25 057
Dependents: 0
Suggesters: 0
Security: 0
Stars: 8
Watchers: 4
Forks: 5
Open Issues: 2
Requires
- php: >=5.6
- guzzlehttp/guzzle: ^6.3
- guzzlehttp/guzzle-services: ^1.1
Requires (Dev)
- ext-curl: *
- phpunit/phpunit: ^5
- psr/log: ^1.0
- ramsey/uuid: ^3.7
- roave/security-advisories: dev-master
- zendframework/zend-config-aggregator: ^1.1
Suggests
- psr/log: Required for using the Log middleware
- ramsey/uuid: Required for using UUID generator
- zendframework/zend-config-aggregator: Required for generating service-description resources
This package is not auto-updated.
Last update: 2020-04-28 13:39:13 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.