$prompt]);
$response = wp_remote_post($api_url, [
‘headers’ => [
‘Content-Type’ => ‘application/json’,
‘x-api-key’ => ‘YOUR_API_KEY_HERE’
],
‘body’ => $body,
]);
if (is_wp_error($response)) {
echo ‘
Error connecting to API.
‘;
} else {
$data = json_decode(wp_remote_retrieve_body($response), true);
echo ‘
API Response:
‘;
echo ‘
‘ . esc_html($data[‘result’]) . ‘
‘;
}
} else {
echo ‘
No prompt found.
‘;
}
get_footer();
?>