Created
June 13, 2021 13:57
-
-
Save seanslater/09ea978a3612871d32cd233e9e576b20 to your computer and use it in GitHub Desktop.
Simple Discord Message Bot using Webhook
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$content = 'Message to send'; | |
$username = 'Discord Bot'; | |
// set your own Discord webhook URL | |
$url = "https://discord.com/api/webhooks/00000000000000000000/000000000000000000000000000000000000000000000000000000000000"; | |
//send message | |
$headers = [ 'Content-Type: application/json; charset=utf-8' ]; | |
$POST = [ 'username' => $username, 'content' => $content ]; | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, $url); | |
curl_setopt($ch, CURLOPT_POST, true); | |
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); | |
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($POST)); | |
$response = curl_exec($ch); | |
exit(); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment