I tried every other way still the response I get from Discord is{"message": "Cannot send an empty message", "code": 50006}
Actually, this is not a problem with Discord because my curl request works fine.
Here’s my curl request snippet.
function discordmsg($site, $errorcode, $desc, $webhook, $name){
$msg = json_decode('{ "content": "Monitoring update, read more in the embed below! If you believe a false alarm has been triggered or something has gone wrong, email us ", "embeds": [ { "title": "Uptime Alert", "description": "Your site '.$site.' ('.$name.') is down, Expected response 200/302, Got response '.$errorcode.' (Which means '.$desc.')",
"color": 16711680, "footer": { "text": "This was given by the automatic monitoring system provided by example" } } ], "username": "Monitoring Update",
"avatar_url": "https://example.com/monitoring/monitoring.png" } ', true);
if($webhook != "") {
$ch = curl_init($webhook);
$msg = "payload_json=" . urlencode(json_encode($msg))."";
if(isset($ch)) {
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $msg);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
}
}
Please tell me how this can be changed into wp_remote_post()