Giter Site home page Giter Site logo

dhl-php-sdk's Introduction

DHL PHP SDK

This unofficial library is wrapping some functions of the DHL SOAP API in order to easy create shipments and labels.

Motivation

I had a lot of pain studying and programming the DHL SOAP API - just to wrap some bits in a lot of XML. There is a lot, but not very helpful, documentation to the API. So I decided to create some functions in an easy to use and understand library.

Prerequirements

You need a DHL developer account and - as long as you want to use the API in production systems - a DHL Intraship Account.

Usage

First of all you need to create the Shipment Object with your credentials and some information from you as shipper.

// your customer and api credentials from/for dhl
$credentials = array(
	'user' => 'geschaeftskunden_api', 
	'signature' => 'Dhl_ep_test1', 
	'ekp' => '5000000000',
	'api_user'  => '',
	'api_password'  => '',
	'log' => true
);


// your company info
$info = array(
	'company_name'    => 'Kindehochdrei GmbH',
	'street_name'     => 'Clayallee',
	'street_number'   => '241',
	'zip'             => '14165',
	'country'         => 'germany',
	'city'            => 'Berlin',
	'email'           => '[email protected]',
	'phone'           => '01788338795',
	'internet'        => 'http://www.kindhochdrei.de',
	'contact_person'  => 'Nina Boeing'
);

With these infos you can create the object:

$dhl = new DHLBusinessShipment($credentials, $info);

To create a shipment and get the shipment number and label, just create the receiver details:

// receiver details
$customer_details = array(
	'first_name'    => 'Tobias',
	'last_name'     => 'Redmann',
	'c/o'           => '',
	'street_name'   => 'Hocksteinweg',
	'street_number' => '11',
	'country'       => 'germany',
	'zip'           => '14165',
	'city'          => 'Berlin'
);

And the create a shipment

$response = $dhl->createNationalShipment($customer_details);

After that, you can read the shipment infos

if($response !== false) {

	var_dump($response);

} else {

	var_dump($dhl->errors);

}

That's all. More will be hopefully coming soon.

Using the live API

To use it in live environment, please create the Client as none sandboxed:

$dhl = new DHLBusinessShipment($credentials, $info, false);

You need also to change the credentials a bit:

// your customer and api credentials from/for dhl
$credentials = array(
	'user' => 'geschaeftskunden_api',
	'signature' => 'Dhl_ep_test1',
	'ekp' => '5000000000',
	'api_user'  => '',
	'api_password'  => '',
	'log' => true
);

user: Use the intraship username
signature: intraship password
ekp: Your dhl customer id
api_user: App ID from developer account
api_password: App token from developer account

WordPress and WooCommerce

I build several Plugins for WordPress and WooCommerce - feel free to ask me for that.

Contact

Check out my website: www.tricd.de

dhl-php-sdk's People

Contributors

tobias-redmann avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.