Skip to content

Instantly share code, notes, and snippets.

@seanslater
Created June 13, 2021 13:57
Show Gist options
  • Save seanslater/09ea978a3612871d32cd233e9e576b20 to your computer and use it in GitHub Desktop.
Save seanslater/09ea978a3612871d32cd233e9e576b20 to your computer and use it in GitHub Desktop.
Simple Discord Message Bot using Webhook
<?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