próbuje się połączyć z DPD UK i pobrać informację o przesyłce.
Mój kod:
$url = "https://apps.geopostuk.com/trackingcore/ie/parcels"; $xml = '<?xml version="1.0" encoding="UTF-8"?> <trackingrequest> <user>user</user> <password>password</password> <trackingnumbers> <trackingnumber>XXXX</trackingnumber> </trackingnumbers> </trackingrequest> </xml>'; $handle = 'output.xml'; $handle = fopen($handle, 'w'); fwrite($handle, $xml); $post_data['xml'] = $handle; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "".$url."" ); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST" ); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_HTTPHEADER, array( "Content-Type: application/xml; charset=UTF-8", "Accept: application/xml; charset=UTF-8", "Authorization: Basic ". base64_encode("user:password") ."", "GEOClient: account/number", "trackingnumbers:XXXXX", "Content-Length: ".$handle."" )); $response = curl_exec($ch); if (curl_errno($ch)) { print curl_error($ch); } curl_close($ch); $result = json_decode($response); 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