I'm trying to make a form send the information to a discord channel, but im having trouble making the webhook connection since it just keeps saying {"message": "Cannot send an empty message", "code": 50006}
This is my code:
$url = "https://discordapp.com/api/webhooks/xxxxxxxxx";
$hookObject = json_encode([
    "content" => "A message will go here",
    "username" => "MyUsername",
], JSON_FORCE_OBJECT);
$ch = curl_init();
var_dump($hookObject);
curl_setopt_array( $ch, [
    CURLOPT_URL => $url,
    CURLOPT_POST => true,
    CURLOPT_POSTFIELDS => $hookObject,
    CURLOPT_HTTPHEADER => [
        "Length" => strlen( $hookObject ),
        "Content-Type" => "application/json"
    ]
]);
$response = curl_exec( $ch );
curl_close( $ch );
 
     
     
    