Тема: cURL - надсилання запитів
Привіт всім. Намагаюся реалізувати створення замовлення через апі почти росії
Вони привели приклад на пітоні, я намагаюся переписати на PHP. Тільки ось ніяк не виходить. Після того як я відправляю запит до їхнього апі я отримую помилку ( Bad Request )
org.springframework.http.converter.HttpMessageNotReadableException
Наскільки я зрозумів то я скоріж за все припускаюся помилки при формуванні запиту curl
$access_token = "*********";
$login_password = "*******";
$ch = curl_init();
$data1 = array(
    "address-type-to" => "Universal Brand",
    "area-to" => "string wsd dsad sa",
    "brand-name" => "название брэнда",
    "building-to" => "Строение",
    "comment" => "Номер заказа",
    "corpus-to" => "Корпус",
    "courier" => true,
    "dimension" => array(
        "height" =>  3,
        "length" =>  9,
        "width" =>  73
    ),
    "envelope-type" => "C4",
    "fragile" => true,
    "given-name" => "string",
    "hotel-to" => "string",
    "house-to" => "string",
    "index-to" => 0,
    "insr-value" => 0,
    "letter-to" => "string",
    "location-to" => "string",
    "mail-category" => "SIMPLE",
    "mail-direct" => 0,
    "mail-type" => "UNDEFINED",
    "mass" => 0,
    "middle-name" => "string",
    "num-address-type-to" => "string",
    "order-num" => "string",
    "payment" => 0,
    "payment-method" => "CASHLESS",
    "place-to" => "string",
    "postoffice-code" => "string",
    "recipient-name" => "string",
    "region-to" => "string",
    "room-to" => "string",
    "slash-to" => "string",
    "street-to" => "string",
    "surname" => "string",
    "tel-address" => 0,
    "with-order-of-notice" => true,
    "with-simple-notice" => true
);
$data = array();
array_push($data, $data1);
$data = json_encode($data);
curl_setopt($ch, CURLOPT_URL, "https://otpravka-api.pochta.ru/1.0/user/backlog");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
//curl_setopt( $ch, CURLOPT_POST, true );
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"Content-Type: application/json",
"Accept: application/json;charset=UTF-8",
"Authorization: AccessToken ".$access_token,
"X-User-Authorization: Basic ".$login_password,
"Content-Length: ".strlen($data)
));  
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_exec($ch);
curl_close($ch);Гляньте одним оком)))








