Сервер принимает в обработку текстовом формате данные через form-data. Не могу понять как правильно эти данные отправить ? Через Postman всё работает корректно. При отправке из кода не видит.
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "site.ru",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"data\"\r\n\r\ndate_start=28-10-2018&Phone=%2B7(978)054-62-98&Email=webdizaine%40gmail.com&Transport%5BCategory_Nasko%5D=3366&Transport%5BMark_Nasko%5D=371531&Transport%5BModel_Nasko%5D=371591&Transport%5BCategory_Nasko_Name%5D=&Transport%5BMark_Nasko_Name%5D=TOYOTA&Transport%5BModel_Nasko_Name%5D=RAV4&Transport%5BYearIssue%5D=2012&Transport%5BPower%5D=180&Transport%5BMaxMass%5D=0&Transport%5BUnladenMass%5D=0&Transport%5BPasQuant%5D=0&ident_type=vin&Transport%5BVIN%5D=JTMDFREV40D003260&Transport%5BBodyNumber%5D=&Transport%5BChassisNumber%5D=&Transport%5BLicensePlate%5D=%D0%90315%D0%9C%D0%9E186&doc_type=31&DocCarSerial=8655&DocCarNumber=753379&DocumentCarDate=07-09-2017&dk_num=061790041700448&dk_date_to=02-05-2019&neogr=0&Drivers%5B1%5D%5BLastName%5D=%D0%9A%D0%B0%D1%80%D0%B5%D0%BB%D0%B8%D0%BD%D0%B0&Drivers%5B1%5D%5BFirstName%5D=%D0%9C%D0%B0%D1%80%D0%B8%D1%8F&Drivers%5B1%5D%5BMiddleName%5D=%D0%9A%D0%BE%D0%BD%D1%81%D1%82%D0%B0%D0%BD%D1%82%D0%B8%D0%BD%D0%BE%D0%B2%D0%B0&Drivers%5B1%5D%5BBirthDate%5D=08-02-1986&Drivers%5B1%5D%5BSex%5D=2&Drivers%5B1%5D%5BSeria%5D+req_kbm=8608&Drivers%5B1%5D%5BNumber%5D+req_kbm=961752&Drivers%5B1%5D%5BExperienceDate%5D=20-07-2004&insurant%5BSurname%5D=%D0%9A%D0%B0%D1%80%D0%B5%D0%BB%D0%B8%D0%BD&insurant%5BName%5D=%D0%9A%D0%BE%D0%BD%D1%81%D1%82%D0%B0%D0%BD%D1%82%D0%B8%D0%BD&insurant%5BPatronymic%5D=%D0%A1%D0%B5%D1%80%D0%B3%D0%B5%D0%B5%D0%B2%D0%B8%D1%87&insurant%5BBirthDate%5D=01-10-1984&insurant%5BSex%5D=1&insurant%5BSeria%5D=7508&insurant%5BNumber%5D=225428&insurant%5BDate_issue%5D=05-05-2008&insurant%5BIssued%5D=%D0%A3%D0%A4%D0%9C%D0%A1&insurant%5BAddress%5D=%D0%A0%D0%B5%D1%81%D0%BF+%D0%9A%D1%80%D1%8B%D0%BC%2C+%D0%B3+%D0%A1%D0%B8%D0%BC%D1%84%D0%B5%D1%80%D0%BE%D0%BF%D0%BE%D0%BB%D1%8C%2C+%D1%83%D0%BB+%D0%91%D0%B0%D0%BB%D0%B0%D0%BA%D0%BB%D0%B0%D0%B2%D1%81%D0%BA%D0%B0%D1%8F%2C+%D0%B4+137+&insurant%5BZip%5D=295013&insurant%5BState%5D=%D0%A0%D0%B5%D1%81%D0%BF+%D0%9A%D1%80%D1%8B%D0%BC&insurant%5BRegion%5D=&insurant%5BCity%5D=%D0%A1%D0%B8%D0%BC%D1%84%D0%B5%D1%80%D0%BE%D0%BF%D0%BE%D0%BB%D1%8C&insurant%5BStreet%5D=%D1%83%D0%BB+%D0%91%D0%B0%D0%BB%D0%B0%D0%BA%D0%BB%D0%B0%D0%B2%D1%81%D0%BA%D0%B0%D1%8F&insurant%5BHouse%5D=137&insurant%5BBuilding%5D=&insurant%5BApartment%5D=&insurant%5Bfias_level%5D=8&insurant%5Bcity_short%5D=%D0%91%D0%B0%D0%BB%D0%B0%D0%BA%D0%BB%D0%B0%D0%B2%D1%81%D0%BA%D0%B0%D1%8F&insurant%5Bcity_kladr_id%5D=9100000700000&insurant%5Bstreet_kladr_id%5D=91000007000015600&insurant%5Bkladr_id%5D=9100000700001560079&insurant%5Bcity_okato_id%5D=35401000000&insurant_is_owner=1&owner%5Bur_name%5D=&owner%5Bur_inn%5D=&owner%5Bur_kpp%5D=&owner%5Bur_doc_ser%5D=&owner%5Bur_doc_num%5D=&owner%5BSurname%5D=%D0%9A%D0%B0%D1%80%D0%B5%D0%BB%D0%B8%D0%BD&owner%5BName%5D=%D0%9A%D0%BE%D0%BD%D1%81%D1%82%D0%B0%D0%BD%D1%82%D0%B8%D0%BD&owner%5BPatronymic%5D=%D0%A1%D0%B5%D1%80%D0%B3%D0%B5%D0%B5%D0%B2%D0%B8%D1%87&owner%5BBirthDate%5D=01-10-1984&owner%5BSex%5D=1&owner%5BSeria%5D=7508&owner%5BNumber%5D=225428&owner%5BDate_issue%5D=05-05-2008&owner%5BIssued%5D=%D0%A3%D0%A4%D0%9C%D0%A1&owner%5BAddress%5D=%D0%A0%D0%B5%D1%81%D0%BF+%D0%9A%D1%80%D1%8B%D0%BC%2C+%D0%B3+%D0%A1%D0%B8%D0%BC%D1%84%D0%B5%D1%80%D0%BE%D0%BF%D0%BE%D0%BB%D1%8C%2C+%D1%83%D0%BB+%D0%91%D0%B0%D0%BB%D0%B0%D0%BA%D0%BB%D0%B0%D0%B2%D1%81%D0%BA%D0%B0%D1%8F%2C+%D0%B4+137+&owner%5BZip%5D=295013&owner%5BState%5D=%D0%A0%D0%B5%D1%81%D0%BF+%D0%9A%D1%80%D1%8B%D0%BC&owner%5BRegion%5D=&owner%5BCity%5D=%D0%A1%D0%B8%D0%BC%D1%84%D0%B5%D1%80%D0%BE%D0%BF%D0%BE%D0%BB%D1%8C&owner%5BStreet%5D=%D1%83%D0%BB+%D0%91%D0%B0%D0%BB%D0%B0%D0%BA%D0%BB%D0%B0%D0%B2%D1%81%D0%BA%D0%B0%D1%8F&owner%5BHouse%5D=137&owner%5BBuilding%5D=&owner%5BApartment%5D=&owner%5Bfias_level%5D=8&owner%5Bcity_short%5D=%D0%91%D0%B0%D0%BB%D0%B0%D0%BA%D0%BB%D0%B0%D0%B2%D1%81%D0%BA%D0%B0%D1%8F&owner%5Bstreet_kladr_id%5D=91000007000015600&owner%5Bstreet_kladr_id%5D=91000007000015600&owner%5Bcity_short%5D=%D0%91%D0%B0%D0%BB%D0%B0%D0%BA%D0%BB%D0%B0%D0%B2%D1%81%D0%BA%D0%B0%D1%8F&owner%5Bcity_kladr_id%5D=9100000700000&owner%5Bstreet_kladr_id%5D=91000007000015600&owner%5Bkladr_id%5D=9100000700001560079&owner%5Bcity_okato_id%5D=35401000000&AgrISN=27169459\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"status_id\"\r\n\r\n172703\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--",
CURLOPT_HTTPHEADER => array(
"Cache-Control: no-cache",
"Content-Type: application/json",
"Postman-Token: f17bbf48-37e7-4a6a-afd2-d098e18ed751",
"content-type: multipart/form-data"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
//print_r(curl_getinfo($curl));
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
print_r($response);
}
?>
Попробуйте передать данные массивом, из официальной справки
Замечание: Передача массива в CURLOPT_POSTFIELDS закодирует данные в виде multipart/form-data, тогда как передача URL-кодированной строки закодирует данные в виде application/x-www-form-urlencoded
Также:
CURLOPT_MAXREDIRS
работает совместно с CURLOPT_FOLLOWLOCATION
, удалите пустой CURLOPT_ENCODING
, непонятно зачем CURLOPT_HTTP_VERSION
, CURLOPT_CUSTOMREQUEST
извращение (замените на CURLOPT_POST
).
Виртуальный выделенный сервер (VDS) становится отличным выбором
Доброй ночи! У меня тут какая-то непонятная ситуацияНапример, в методе readMapSettings() в waterBody
В задании по С++ сказанно отсортирвать массив названий товаров продуктового магазина по алфавиту на русскомС английской сортировкой в Java мне...