Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> CURL DPD UK, API DPD UK
casperii
post
Post #1





Grupa: Zarejestrowani
Postów: 681
Pomógł: 28
Dołączył: 14.08.2014

Ostrzeżenie: (0%)
-----


Witam,
próbuje się połączyć z DPD UK i pobrać informację o przesyłce.
Mój kod:

  1. $url = "https://apps.geopostuk.com/trackingcore/ie/parcels";
  2. $xml = '<?xml version="1.0" encoding="UTF-8"?>
  3. <trackingrequest>
  4. <user>user</user>
  5. <password>password</password>
  6. <trackingnumbers>
  7. <trackingnumber>XXXX</trackingnumber>
  8. </trackingnumbers>
  9. </trackingrequest>
  10. </xml>';
  11.  
  12. $handle = 'output.xml';
  13. $handle = fopen($handle, 'w');
  14. fwrite($handle, $xml);
  15. $post_data['xml'] = $handle;
  16.  
  17. $ch = curl_init();
  18. curl_setopt($ch, CURLOPT_URL, "".$url."" );
  19. curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST" );
  20. curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
  21. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  22. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  23. curl_setopt($ch, CURLOPT_HTTPHEADER, array(
  24. "Content-Type: application/xml; charset=UTF-8",
  25. "Accept: application/xml; charset=UTF-8",
  26. "Authorization: Basic ". base64_encode("user:password") ."",
  27. "GEOClient: account/number",
  28. "trackingnumbers:XXXXX",
  29. "Content-Length: ".$handle.""
  30. ));
  31. $response = curl_exec($ch);
  32.  
  33. if (curl_errno($ch)) {
  34. print curl_error($ch);
  35. }
  36. curl_close($ch);
  37. $result = json_decode($response);
  38. echo var_dump($response);


Natomiast serwer zwraca mi: Client sent a bad request.
Gdyby jednak ktoś chciał zajrzeć w dokumentacje DPD UK:

Server: ftp.geopostuk.com
User: edidev
Password: acy7bies
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 2.10.2025 - 16:38