added raw message
This commit is contained in:
@@ -62,6 +62,43 @@ class DiscordMessage extends IPSModule {
|
||||
///echo "Webhook Response: " . $response;
|
||||
|
||||
|
||||
}
|
||||
public function SendMessageRaw($data) {
|
||||
|
||||
// Discord webhook URL
|
||||
$webhookUrl = $this->ReadPropertyString("DiscordWsUrl");
|
||||
|
||||
// Encode the data as JSON
|
||||
$jsonData = json_encode($data);
|
||||
|
||||
// Initialize cURL session
|
||||
$ch = curl_init($webhookUrl);
|
||||
|
||||
// Set cURL options
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
|
||||
"Content-Type: application/json",
|
||||
"Content-Length: " . strlen($jsonData)
|
||||
));
|
||||
|
||||
// Execute the cURL session and capture the response
|
||||
$response = curl_exec($ch);
|
||||
|
||||
// Check for cURL errors
|
||||
if (curl_errno($ch)) {
|
||||
echo "cURL Error: " . curl_error($ch);
|
||||
}
|
||||
|
||||
// Close cURL session
|
||||
curl_close($ch);
|
||||
|
||||
// Display the response from the webhook
|
||||
///echo "Webhook Response: " . $response;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user