public function testDHL() { $dhl = config('dhl'); // Test a getQuote using DHL XML API $sample = new GetQuote(); $sample->SiteID = "DHLMexico"; $sample->Password = "******"; // Set values of the request $sample->MessageTime = date("c"); $sample->MessageReference = '1234567890123456789012345678901'; $sample->BkgDetails->Date = date('Y-m-d'); $piece = new PieceType(); $piece->PieceID = 1; $piece->Height = 10; $piece->Depth = 5; $piece->Width = 10; $piece->Weight = 10; $sample->BkgDetails->addPiece($piece); $sample->BkgDetails->IsDutiable = 'N'; $sample->BkgDetails->ReadyTime = 'PT10H21M'; $sample->BkgDetails->ReadyTimeGMTOffset = '+01:00'; $sample->BkgDetails->DimensionUnit = 'CM'; $sample->BkgDetails->WeightUnit = 'KG'; $sample->BkgDetails->PaymentCountryCode = 'MX'; $sample->From->CountryCode = 'MX'; $sample->From->Postalcode = '15700'; $sample->From->City = 'DF'; $sample->To->CountryCode = 'MX'; $sample->To->Postalcode = '35078'; $sample->To->City = 'DURANGO'; // Call DHL XML API $start = microtime(true); echo $sample->toXML(); $client = new WebserviceClient('staging'); $xml = $client->call($sample); echo PHP_EOL . 'Executed in ' . (microtime(true) - $start) . ' seconds.' . PHP_EOL; echo $xml . PHP_EOL; $array_xml = json_decode(json_encode(simplexml_load_string($xml)), true); print_r($array_xml); }
$piece->PieceID = 1; $piece->Height = 10; $piece->Depth = 5; $piece->Width = 10; $piece->Weight = 10; $sample->BkgDetails->addPiece($piece); $sample->BkgDetails->IsDutiable = 'Y'; $sample->BkgDetails->QtdShp->QtdShpExChrg->SpecialServiceType = 'WY'; $sample->BkgDetails->ReadyTime = 'PT10H21M'; $sample->BkgDetails->ReadyTimeGMTOffset = '+01:00'; $sample->BkgDetails->DimensionUnit = 'CM'; $sample->BkgDetails->WeightUnit = 'KG'; $sample->BkgDetails->PaymentCountryCode = 'CA'; $sample->BkgDetails->IsDutiable = 'Y'; // Request Paperless trade $sample->BkgDetails->QtdShp->QtdShpExChrg->SpecialServiceType = 'WY'; $sample->From->CountryCode = 'CA'; $sample->From->Postalcode = 'H3E1B6'; $sample->From->City = 'Montreal'; $sample->To->CountryCode = 'CH'; $sample->To->Postalcode = '1226'; $sample->To->City = 'Thonex'; $sample->Dutiable->DeclaredValue = '100.00'; $sample->Dutiable->DeclaredCurrency = 'CHF'; // Call DHL XML API $start = microtime(true); echo $sample->toXML(); $client = new WebserviceClient('staging'); $xml = $client->call($sample); echo PHP_EOL . 'Executed in ' . (microtime(true) - $start) . ' seconds.' . PHP_EOL; echo $xml . PHP_EOL;