PHP code example of php-channels / discord-webhook
1. Go to this page and download the library: Download php-channels/discord-webhook library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
php-channels / discord-webhook example snippets
use PhpChannels\DiscordWebhook\Discord;
...
Discord::message('https://discord.com/api/webhooks/your-webhook-path')
->setUsername('My Bot')
->setContent('Hello World!')
->send();
use PhpChannels\DiscordWebhook\Discord;
...
Discord::message('https://discord.com/api/webhooks/your-webhook-path');
// ...
use PhpChannels\DiscordWebhook\Discord;
...
Discord::message()
->setWebhook('https://discord.com/api/webhooks/your-webhook-path');
// ...
use PhpChannels\DiscordWebhook\Discord;
...
Discord::message('https://discord.com/api/webhooks/your-webhook-path')
->setUsername('Your Name')
->setContent('Hello World!')
->send();
use PhpChannels\DiscordWebhook\Discord;
...
Discord::message('https://discord.com/api/webhooks/your-webhook-path')
->setUsername('My Bot')
->setContent('Hello World!')
->setAvatar('https://fake-avatar.com/avatar.png')
->send();
use PhpChannels\DiscordWebhook\Discord;
...
Discord::message('https://discord.com/api/webhooks/your-webhook-path')
->setContent('A simple text message you want to send!')
->send();
use PhpChannels\DiscordWebhook\Discord;
...
Discord::message('https://discord.com/api/webhooks/your-webhook-path')
->setTitle('Your title here!')
->send();
use PhpChannels\DiscordWebhook\Discord;
...
Discord::message('https://discord.com/api/webhooks/your-webhook-path')
->setUrl('https://fake-url.com')
->send();
use PhpChannels\DiscordWebhook\Discord;
...
Discord::message('https://discord.com/api/webhooks/your-webhook-path')
->setDescription('Your description here!')
->send();
use PhpChannels\DiscordWebhook\Discord;
...
Discord::message('https://discord.com/api/webhooks/your-webhook-path')
->setColor('2450411')
->send();
use PhpChannels\DiscordWebhook\Discord;
...
Discord::message('https://discord.com/api/webhooks/your-webhook-path')
->setColor('info')
->send();