[img]https://i.sstatic.net /NwmLF.png[/img]
но вопрос в том, как отправить аналогичный запрос с помощью laravel http?
что я сделал:
Код: Выделить всё
public function performMultiPartRequest($requestUrl, $body)
{
$response = Http::withHeaders(['Accept' => 'application/json']);
$data = [];
foreach ($body as $key => $value) {
if (gettype($value) == 'string') // for string data. works well.
array_push($data,[$key, $value]);
else if (gettype($value) == 'array') { // array of files. doesn't work!
foreach ($value as $file) {
$extension = $file->getClientOriginalExtension();
$response->attach($key , fopen($file, 'r'), mt_rand(100,1000).".".$extension);
}
}
else { // one file. works well.
$extension = $value->getClientOriginalExtension();
$response->attach($key, fopen($value, 'r'), 'temp.'.$extension);
}
}
$response = $response->post($this->baseUri.$requestUrl, $body);
return $response;
}
сообщение об ошибке:
Код: Выделить всё
A 'contents' key is requiredПодробнее здесь: https://stackoverflow.com/questions/654 ... uzzle-http
Мобильная версия