[
'Authorization' => 'Bearer ' . $api_key,
'Content-Type' => 'application/json',
],
'body' => json_encode([
'prompt' => $prompt,
'image' => $base64,
'n' => 1,
'size' => '1024x1024',
'response_format' => 'url'
])
]); if (!is_wp_error($response)) {
$body = json_decode(wp_remote_retrieve_body($response), true);
$image_url = $body['data'][0]['url']; // Guardar en sesión y redirigir
session_start();
$_SESSION['imagen_generada'] = $image_url;
wp_redirect(site_url('/resultado'));
exit;
} else {
echo "Error al generar la imagen. Inténtalo más tarde.";
}
} else {
echo "Falta la imagen o el estilo.";
}
} else {
echo "Acceso incorrecto.";
}
?>