0

I am trying to track a shipment to get the status and date of it. For that I was checking the DHL documentation from the site in Germany, but is not really good to be honest.

Anyways, there's a testsuite which I downloaded and read, and there they say:

If you are working with the GET method, you can also view the link, all necessary information is contained in the URL.

Here you will find the complete URL as the first entry:

GET https://cig.dhl.de/services/sandbox/rest/sendungsverfolgung?xml=%3C%3Fxml%20version%3D%221.0%22%20encoding%3D%22UTF-8%22%20standalone%3D%22no%22%3F%3E%20%3Cdata%20appname%3D%22zt12345%22%20language-code%3D%22de%22%20password%3D%22geheim%22%20piece-code%3D%2200340434161094015902%22%20request%3D%22d-get-piece-detail%22%2F%3E%20 HTTP/1.1

You can also put this link into your browser. (doing that doesn't work for me) That link supposed to output in XML format.

So my question is...How can I get the info from that URL in PHP? to then be able to retrieve the specific info in it.

Georgy
  • 12,464
  • 7
  • 65
  • 73
Daniel Soublett
  • 849
  • 2
  • 8
  • 23
  • To me, the "link" looks like as it is already url-encoded, what most browsers would do again for the input url. You would have to replace all `%xx` by the de-hexacedimalized character eg `%20`->space – Stefan Hegny Jan 30 '19 at 22:03
  • if the information is contained in the URL, you can `parse_str` (php) the url, and `url_decode` (php) the xml parameter in the query part. what you'll get is a ..... string probably? wrapped in some xml-nonsense. so you could run it through an xml parser and what not ... sounds like an awful lot of work ^^ – Jakumi Jan 30 '19 at 22:16
  • so, what is after the `?xml=` is the following: ` ` I don't know what kind of information you're looking for though ... – Jakumi Jan 30 '19 at 22:21

1 Answers1

0

I think the best way will be to use this library which implements the DHL API methods quite well: https://github.com/alfallouji/DHL-API

You might also refer to this post where they discuss different ways of using the API: DHL Tracking Api and PHP

marcus.kreusch
  • 648
  • 5
  • 15