ตัวอย่าง notify Discord
<?php
if(!empty($_POST['mess'])){
$mess = $_POST['mess'];
$webhookURL = "https://discord.com/api/webhooks/1356835416002662407/rOdCmDjs6VHyOc8WnAVbNjFvOIsCeUt7amqXEhrugksSD47spyeF5SGWIxkQcJAcNKGO"; // ใส่ Webhook URL ที่ได้จาก Discord
$message = json_encode(["content" => "$mess"]);
$options = [
'http' => [
'header' => "Content-Type: application/json\r\n",
'method' => 'POST',
'content' => $message
]
];
$context = stream_context_create($options);
$result = file_get_contents($webhookURL, false, $context);
echo $result;
$result = curl_exec( $chOne );
}
?>
<form method="post" action="">
<textarea id="mess" name="mess" class="form-control" rows="4" cols="50">
ข้อความ
</textarea>
<br>
<button type="submit" class="btn btn-success upload-result">บันทึกข้อมูล</button>
</form>