Giter Site home page Giter Site logo

alfallouji / dhl-api Goto Github PK

View Code? Open in Web Editor NEW
190.0 33.0 147.0 188 KB

This library provides a PHP client for the DHL XML Services. DHL XML Services is an online web services integration capability that provides DHL’s service availability, transit times, rates, shipment and courier pickup booking along with shipment tracking from over 140 countries around the world. Using DHL’s XML Services, customers can incorporate DHL shipping functionality into their websites, customer service applications or order processing systems.

PHP 100.00%

dhl-api's Issues

How to get the credential

Hi ,

I want to use the DHL api shipment tracking service from gemany.

How can I create account : I mean

return array(
'dhl' => array(
'id' => 'Your_DHL_ID',
'pass' => 'Your_DHL_Password',
'shipperAccountNumber' => 'Your_Number',
'billingAccountNumber' => 'Your_Number',
'dutyAccountNumber' => 'Your_Number',
),
);

Here what is 'id' => 'Your_DHL_ID' and password
I tried to create an account as mentioned in the doc. But I git a mail saying that

http://www.dhl.com/en/express/resource_center/integrated_shipping_solutions.html
Just click on “Start developing with DHL XML Services” and select your country. Then, select “Request DHL Integration Solutions Toolkit / Developer Guides” and choose your country again under “Choose a Location”.

But when I go to this link there is no option to select select “Request DHL Integration Solutions Toolkit / Developer Guides”

Can someone help here ?

Trying to get property of non-object

When using the initFromXML method as below :-

$client = new WebserviceClient('staging');
$xml = $client->call($request);
$response = new ShipmentResponse();
$response->initFromXML($xml);

The line - $response->initFromXML($xml);
gives :-

• Error in Base.php line 227
• at HandleExceptions->handleError('8', 'Trying to get property of non-object', '/var/www/dlogistics/vendor/alfallouji/dhl_api/DHL/Entity/Base.php', '227', array('xml' => object(SimpleXMLElement), 'this' => object(ShipmentResponse))) in Base.php line 227

I believe the code in the Base.php class

    if ((string) $xml->Response->Status->Condition->ConditionCode != '')
    {
        $errorMsg = ((string) $xml->Response->Status->Condition->ConditionCode) . ' : ' . ((string) $xml->Response->Status->Condition->ConditionData);
        throw new \Exception('Error returned from DHL webservice : ' . $errorMsg);
    }

Is failing because the entity “Condition code” does not exist in the XML returned by DHL (no errors).

Sample XML for request and response attached (label and licenceplates removed to avoid bloat).

XML.txt

AddressLine issue

Hi Al-fallouji
I try to use multiple line address to shipment request, but it's not work.
It's a sample (sample/GB/ShipmentRequest.php)
There are two address line on your sample code.
$sample->Shipper->AddressLine = '1 New Orchard Road';
$sample->Shipper->AddressLine = 'Armonk';

The result of XML only one line => Armonk

How can i use the multiple line of address?

Thank you for your time.

Sincerely,

Alan Sun

Issue in geeting Cost for DHL shipping services

The issue is when I am sending the request to DHL for getting cost of services provided by DHL like Express Domestic, Express Worldwide etc then I am getting the response as " System Unavailable:DCT webservice host is not reachable " most of the times, also sometimes I got the shipping charges and offered services details too.

That's why It is creating issue.

Not working GB/BookPURequest function

Hi. Dear
Now BookPuRequest xml sechma upgarde 3.0
So current it's not working.
I have just upload changed source code.
Pls upgrade friendly.
Kind regards.

Pick Sample

hello there,
thank you very much for your good job!
can you put an example of PickUp please?
thank you
Nizar

/rest/v2/Label

"Input validation failed : Unable to process label request.Please provide correct request messag

Add DocImages node

hi!
how to add a DocImages node?
$docimage = new DocImage();
$docimage->Type = 'CIN';
$docimage->Image = '';
$docimage->ImageFormat = 'PDF';
$sample->DocImages->addDocImage($docimage);
don't work
Ps: sorry for my english

how to track the order information?

hello alfallouji !
when i use the DHL-API,There is no corresponding method to track the order information !
Can you give an example? thank you !

Cannot determine destination service

Fatal error: Uncaught exception 'Exception' with message 'Error returned from DHL webservice : SV011c : Cannot determine destination service. Check recipient postal code, city and country or complete an airwaybill manually. For assistance call DHL customer services.' in C:\xampp\htdocs\dhl\DHL\Entity\Base.php:230 Stack trace: #0 C:\xampp\htdocs\dhl\samples\GB\ShipmentRequest.php(150): DHL\Entity\Base->initFromXML('<?xml version="...') #1 {main} thrown in C:\xampp\htdocs\dhl\DHL\Entity\Base.php on line 230

getQuote - all methods at once?

Hi!
Is there a way to get the quote for some particular method?
I don't understand what am I getting in the response. In is a node per method? I see there is one LocalProductName -> MEDICAL EXPRESS and then another for EXPRESS WORLDWIDE.

thanks for the answer

How to retrieve 6x4 labels

Thanks for providing a class that undoubtedly has been of great use to many.

I need to retrieve the label in the 6x4 format which is suported using the DHL 4.0 spec. Is it just a case of changing the 'LabelTemplate' enumerator values in the Label.php classes to include 6X4_PDF (seems to work). If so would it be possible to include this in your classes?

Thanks

Lack of type "6X4_PDF,8X4_PDF" in Datatype/*/Label

'LabelTemplate' => array( 'type' => 'LabelTemplate', 'required' => false, 'subobject' => false, 'comment' => 'LabelTemplate', 'enumeration' => '8X4_A4_PDF,8X4_thermal,8X4_A4_TC_PDF,6X4_A4_PDF,6X4_PDF,8X4_PDF, ![a](https://cloud.githubusercontent.com/assets/6942348/26087037/15a14b64-3a21-11e7-85fb-9f5ad4a74745.png) 6X4_thermal,8X4_CI_PDF,8X4_CI_thermal', ),

PickUp

hello,
thank you very much for your good job!
can you put an example of PickUp please?
thank you
Nizar

How to display a PDF label ?

Received the following email :

Hi Bashar,

Your DHL library on GIT will certainly help a lot of folks like me, thanks.

Have a question as when do a Validation request, upon success the XML generated gives binary of barcode and images - do you have any idea how I could show this on a proper PDF file ?

Thanks in advance.

best regards,

Biplov gautam

Multiple SpecialServiceType for the shipment validation request is not working as expected

The following sample code from the file ShipmentRequest.php is accepting only one type, in this case just "I".

$sample->SpecialService->SpecialServiceType = 'A';
$sample->SpecialService->SpecialServiceType = 'I';

I need the output to be like this

<specialservice>
    <specialservicetype>A</specialservicetype>
</specialservice>

<specialservice>
    <specialservicetype>I</specialservicetype>
</specialservice>

PickUp example

Hi alfallouji,
thanks very much for your awesome work!
Can you show an example for PickUp? I've tried it for many hours but i did not succeed.

Thanks,
Carlo

Multiple pieces in shipment request

Hello,

Congratulations on DHL-APi, very nice work.
One question. How can you add multiple shipment pieces in shipment request.
For example:

$sample->ShipmentDetails->NumberOfPieces = '2';
$sample->ShipmentDetails->Pieces->Piece->PieceID = '1';
$sample->ShipmentDetails->Pieces->Piece->PackageType = 'EE';
$sample->ShipmentDetails->Pieces->Piece->Weight = '10.0';
$sample->ShipmentDetails->Pieces->Piece->DimWeight = '1200.0';
$sample->ShipmentDetails->Pieces->Piece->Width = '100';
$sample->ShipmentDetails->Pieces->Piece->Height = '200';
$sample->ShipmentDetails->Pieces->Piece->Depth = '300';
$sample->ShipmentDetails->Pieces->Piece->PieceID = '2';
$sample->ShipmentDetails->Pieces->Piece->PackageType = 'EE';
$sample->ShipmentDetails->Pieces->Piece->Weight = '15.0';
$sample->ShipmentDetails->Pieces->Piece->DimWeight = '1100.0';
$sample->ShipmentDetails->Pieces->Piece->Width = '50';
$sample->ShipmentDetails->Pieces->Piece->Height = '50';
$sample->ShipmentDetails->Pieces->Piece->Depth = '100';

But it accepts only one piece. How can I add another one?

Thank you for your time.

Sincerely,

Marko Jovanovic

Using with composer autoloader

Hi

I have issues with using your package via autoloader provided by composer.
It's dead simple as following:

{
    "name": "symfony/framework-standard-edition",
    "license": "MIT",
    "type": "project",
    "description": "The \"Symfony Standard Edition\" distribution",
    "autoload": {
        "psr-0": {
            "": "src/"
        }
    },
    "require": {
        "php": ">=5.3.3",
        "symfony/symfony": "2.3.*",
        "doctrine/orm": "^2.4.8",
        "doctrine/doctrine-bundle": "~1.2",
        "twig/extensions": "~1.0",
        "symfony/assetic-bundle": "~2.3",
        "symfony/swiftmailer-bundle": "~2.3",
        "symfony/monolog-bundle": "~2.4",
        "sensio/distribution-bundle": "~2.3",
        "sensio/framework-extra-bundle": "^3.0.2",
        "sensio/generator-bundle": "~2.3",
        "incenteev/composer-parameter-handler": "~2.0",
        "alfallouji/dhl_api": "^0.2.6"
    },
    "scripts": {
        "post-install-cmd": [
            "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
        ],
        "post-update-cmd": [
            "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
        ]
    },
    "config": {
        "bin-dir": "bin",
        "platform": {
            "php": "5.3.3"
        }
    },
    "minimum-stability": "stable",
    "extra": {
        "symfony-app-dir": "app",
        "symfony-web-dir": "web",
        "incenteev-parameters": {
            "file": "app/config/parameters.yml"
        },
        "branch-alias": {
            "dev-master": "2.3-dev"
        }
    }
}

This is typical symfony startup project. I just call a method in controller on a button press to run DHL related code. But PHP crashes on the very first line:

    $shipmentRequest = new ShipmentRequest();

saying it cannot locate class:

FatalErrorException: Error: Class 'DHL\Entity\GB\ShipmentRequest' not found in /home/kraplax/dhl_test/src/AppBundle/Controller/DhlController.php line 30

Is there a solution?

getting error while hit ShipmentRequest from sample

Notice: Trying to get property 'ConditionCode' of non-object in /home/shashi/projects/dhl-api/DHL/Entity/Base.php on line 235

Fatal error: Uncaught InvalidArgumentException: Field : Barcodes is not defined for DHL\Entity\GB\ShipmentResponse in /home/shashi/projects/dhl-api/DHL/Datatype/Base.php:272 Stack trace: #0 /home/shashi/projects/dhl-api/DHL/Entity/Base.php(256): DHL\Datatype\Base->__get('Barcodes') #1 /home/shashi/projects/dhl-api/ShipmentRequest.php(158): DHL\Entity\Base->initFromXML(Object(SimpleXMLElement)) #2 {main} thrown in /home/shashi/projects/dhl-api/DHL/Datatype/Base.php on line 272
ShipmentRequest.zip

ShipmentValidationRequest XML issue

Hi Al-fallouji,
Thank you for providing this, its been extremely helpful!

I ran into an issue while using the ShipmentValidateRequest object. Whenever I try to convert this object into XML, I get an XML piece element placed in another XML piece element.The XML in question. I am using the ShipmentValidateRequest located in Entity/AM folder.

     <Pieces>
         <Piece>
            <Piece>
               <PieceID>1</PieceID>
               <PackageType>CP</PackageType>
               <Weight>2</Weight>
               <Width>1</Width>
               <Height>1</Height>
               <Depth>1</Depth>
               <PieceContents>box</PieceContents>
            </Piece>
         </Piece>
      </Pieces>

the code in question I'm using to add pieces to the object:

foreach ($this->packages as $package) {
 $piece = new Piece();
 $piece->PieceID = $package->id;
 $piece->PackageType = 'CP'; 
 $piece->Weight = ceil($package->weight);
 $piece->Width = ceil($package->width);
 $piece->Height = ceil($package->height);
 $piece->Depth = ceil($package->length);

 $shipmentConfirmationRequest->ShipmentDetails->addPiece($piece);
}

I don't know if its an issue with the toXML function that your client is using, or if its another issue. Any help would be appreciated.

Thank you for your time,

Jason

Fatal error

There is a PHP fatal error when 『$response->initFromXML($xml);』 on the ShipmentRequest.php.
PHP Fatal error: Call to a member function children() on a non-object in /Users/alansun/Sites/DHL-API/DHL/Entity/Base.php on line 191

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.