Releases: kerogs/Discord-webhooks-php
Releases · kerogs/Discord-webhooks-php
2.1
Simple message
<?php
// ? Your Discord Webhook URL (by default try to take from .env file if exists)
$webhook_url = getenv('DISCORD_WEBHOOK_URL') ?: 'https://discord.com/api/webhooks/1436694620691234966/Gh73ZFyvPNwGS9hu2OX3KLigb9TJUjhO1TdSuYN8mO1OLF5YrcPqctJmdV8fAUtUkHNk';
$msg = [
"avatar_url" => "", // avatar url
"username" => "", // username required
"content" => "", // default message content
];
$headers = array('Content-Type: application/json');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $webhook_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($msg));
$response = curl_exec($ch);
curl_close($ch);
echo $response;Embed message
<?php
// ? Your Discord Webhook URL (by default try to take from .env file if exists)
$webhook_url = getenv('DISCORD_WEBHOOK_URL') ?: 'YOUR_DISCORD_WEBHOOK_URL_HERE';
$msg = [
"avatar_url" => "", // avatar url
"username" => "", // username required
"content" => "", // default message content
"embeds" => [
[
"color" => 0xb7996d, // embed color
"author" => [
"name" => "",
"url" => "", // name url
"icon_url" => ""
],
"title" => "",
"url" => "", // url for the title
"description" => "",
"timestamp" => "",
"fields" => [
[
"name" => "",
"value" => "",
"inline" => true
],
[
"name" => "",
"value" => "",
"inline" => true
],
[
"name" => "",
"value" => "",
],
[
"name" => "",
"value" => "",
]
],
"footer" => [
"text" => "",
"icon_url" => "",
],
"image" => [
"url" => ""
],
"thumbnail" =>[
"url" => ""
],
]
],
];
$headers = array('Content-Type: application/json');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $webhook_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($msg));
$response = curl_exec($ch);
curl_close($ch);
echo $response;What's Changed
- spotify example added by @Jageun101 in #2
New Contributors
- @Jageun101 made their first contribution in #2
Full Changelog: v1.0.0...2.1