S
S
siroper2020-08-07 17:12:23
PHP
siroper, 2020-08-07 17:12:23

How to make a request and get the response xml SDEK api?

Hello. I use SDEK API 1.5 (due to an extremely old site on an old version of php). You need to create an order through the API, I do this:

<?php
$soap = curl_init('https://integration.cdek.ru/new_orders.php');
curl_setopt($soap, CURLOPT_POST, 1);
curl_setopt($soap, CURLOPT_RETURNTRANSFER, 1);

date_default_timezone_set('UTC');
$date = date('c');
$secure = md5($date.'&JUSHGFnlu.............yv4HDFfdh2');

$request = <<<XML
<?xml version="1.0" encoding="UTF-8" ?> 
<DeliveryRequest Number="236" Date="2020-08-07T16:54:10" Account="hjyT9687bjkhg78GiutTOGLbhjGO87DD" Secure="<?=$secure?>" 
OrderCount="1">
<Order Number="1010203040"  
DeliveryRecipientCost="0"   
SendCityCode="270"      
RecCityCode="44"    
RecipientName="Тест"    
Phone="7810999, 9295849151"     
Comment="Тест"  TariffTypeCode="5"  RecientCurrency="RUB"   
ItemsCurrency="RUB">    
<Address PvzCode="MSK2" />  
<Package Number="1" BarCode="101" Weight="630">        
<Item 
WareKey="25000050368" 
Cost="49" 
Payment="49" 
Weight="68" 
Amount="1" 
Comment="Тест"/>       
<Item WareKey="25000348563" 
Cost="79" 
Payment="79"
Weight="95" 
Amount="1" 
Comment="вы"/>      
</Package>  
<AddService ServiceCode="30"></AddService>   
</Order> 
</DeliveryRequest>
XML;

curl_setopt($soap, CURLOPT_POSTFIELDS, [
    'xml_request' => $request
]);

$headers = array();
$headers[] = 'Content-Type: application/x-www-form-urlencoded';
curl_setopt($soap, CURLOPT_HTTPHEADER, $headers);


$result = curl_exec($soap);
if (curl_errno($soap)) {
    echo 'Error:' . curl_error($soap);
}
curl_close ($soap);

echo "<pre>";
print_r($result);
echo "</pre>";
?>


But in response to some fig, no error is returned, nothing like that, namely, an incomprehensible 16-digit character set and EVERYTHING !! For example 052a064064052211

What could be the problem?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question