= '2023-05-03';
                  
                  
                  $array['senderCityId'] = '44';
                  
                  
                  $array['receiverCityId'] = '44'; 
                  
                  
                  $array['tariffId'] = '1'; 
                  
                  
                  $array['goods'] = [
                  
                  
                          [
                  
                  
                              'weight' => '0.5',
                  
                  
                              'length' => '5',
                  
                  
                              'width' => '20',
                  
                  
                              'height' => '10'
                  
                  
                          ]
                  
                  
                      ]; 
                  
                  
                  
                  
                  
                  $ch = curl_init('https://api.cdek.ru/calculator/calculate_price_by_json.php');
                  
                  
                  curl_setopt($ch, CURLOPT_POST, 1);
                  
                  
                  curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($array, JSON_UNESCAPED_UNICODE)); 
                  
                  
                  curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
                  
                  
                  curl_setopt($ch, CURLOPT_TIMEOUT, 30);
                  
                  
                  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
                  
                  
                  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
                  
                  
                  curl_setopt($ch, CURLOPT_HEADER, false);
                  
                  
                  $html = curl_exec($ch);
                  
                  
                  curl_close($ch);
                  
                  
                  $res = json_decode($html, true);
                  
                  
                
а у них есть на сайте виджет, там можно посмотреть как именно у них сделано
Обсуждают сегодня