PHP code example of louisgjbertrand / discordwebhook

1. Go to this page and download the library: Download louisgjbertrand/discordwebhook 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/ */

    

louisgjbertrand / discordwebhook example snippets




use LouisGJBertrand\DiscordWebhook\DiscordWebhook;

DiscordWebhook::Send($webhookurl, content: $content, response: $response);

static public function Send(
        string $webhookurl,
        string $content = null,
        string $username = null,
        string $avatar_url = null,
        bool $tts = false,
        array $embeds = null,
        string &$response = null)

$embed = DiscordWebhook::GenerateEmbed(title: "test", description: "test embeded message");
$embeds = [$embed];

static public function GenerateEmbed(
        string $title = null,
        string $type = null,
        string $description = null,
        string $url = null,
        int $timestamp = null,
        int $color= null,
        array $footer= null,
        array $image= null,
        array $thumbnail= null,
        array $video= null,
        array $provider= null,
        array $author= null,
        array $fields= null): array



use LouisGJBertrand\DiscordWebhook\DiscordWebhook;


// Replace with the webhook url
$webhookurl = "https://discord.com/api/webhooks/.../...";


$embed = DiscordWebhook::GenerateEmbed(title: "test", description: "test embeded message");
$embeds = [$embed];

DiscordWebhook::Send($webhookurl, embeds: $embeds, response: $response);

// returns the response from the Discord API
var_dump($response);
ini
# in the php.ini file
extension=curl