curl_setopt($ch, CURLOPT_HTTPHEADER, [
'X-Key: Key '.$xKey,
'X-Secret: Secret '.$xSecret,
"Content-Type: multipart/form-data; boundary=\"" . $boundary."\"",
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, '--'.$boundary.'
Content-Disposition: form-data; name="model_id"
4
--'.$boundary.'
Content-Disposition: form-data; name="params"
Content-Type: application/json
'.$data['params'].'
--'.$boundary.'--');
$ch = curl_init($url);
$data = [
'params' => json_encode([
"type" => "GENERATE",
"numImages" => 1,
"width" => 1024,
"height" => 1024,
'generateParams' => [
'query' => 'море'
]
]),
'model_id' => '4'
];
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'X-Key: Key '.$xKey,
'X-Secret: Secret '.$xSecret,
'Content-Type: application/json'
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$response = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Ошибка: ' . curl_error($ch);
} else {
echo 'Ответ: ' . $response;
}
curl_close($ch);