PHP code example of internet / intercord

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

    

internet / intercord example snippets


use Internet\InterCord\RichEmbed;
use Internet\InterCord\Webhook;

$webhook = Webhook::fromUrl($url);

$webhook->execute('Deploy finished.');

$webhook->execute([
    'Deploy finished.',
    (new RichEmbed())
        ->setTitle('api v4.2.0')
        ->setDescription('Rolled out to all regions.')
        ->setColor('#2ECC71')
        ->addField('Duration', '3m 12s', inline: true)
        ->addField('Errors', '0', inline: true)
        ->setTimestamp(time()),
], username: 'Deploy Bot');

$message = $webhook->executeAndWait('Build #812 started…');

$message->id;          // Snowflake
$message->content;     // 'Build #812 started…'
$message->timestamp;   // DateTimeImmutable
$message->embeds;      // as Discord returned them, proxy URLs and dimensions 

$webhook->getMessage($id);
$webhook->editMessage($id, 'Build #812 passed.');
$webhook->deleteMessage($id);

use Internet\InterCord\Payload;
use Internet\InterCord\PayloadField;

$message->edit((new Payload())->setContent('Embeds removed.')->clear(PayloadField::Embeds));

use Internet\InterCord\AllowedMentions;
use Internet\InterCord\Payload;

$payload = (new Payload())
    ->setContent("New ticket from {$name}")
    ->setUsername('Helpdesk')
    ->setAvatar('https://example.com/helpdesk.png')
    ->setAllowedMentions(AllowedMentions::none())
    ->suppressEmbeds()
    ->suppressNotifications();

$webhook->execute($payload);

use Internet\InterCord\RichEmbed;

$embed = (new RichEmbed())
    ->setTitle('Incident resolved')
    ->setURL('https://status.example.com/incidents/42')
    ->setDescription('Elevated error rates on checkout.')
    ->setColor(0xE74C3C)                // or '#E74C3C', '#E7C', or new Color(231, 76, 60)
    ->setAuthor('Status Page', 'https://status.example.com', 'https://example.com/icon.png')
    ->setThumbnail('https://example.com/thumb.png')
    ->setImage('https://example.com/graph.png')
    ->addField('Started', '14:02 UTC', inline: true)
    ->addField('Resolved', '14:37 UTC', inline: true)
    ->setFooter('On-call: Platform')
    ->setTimestamp('2026-10-19 14:37', 'Y-m-d H:i');

$message = $webhook->executeAndWait('Nightly results', threadId: $threadId);
$message->edit('Nightly results: all green');

$post = $webhook->executeAndWait(
    (new Payload())
        ->setContent('This week: 14 deploys, 0 rollbacks.')
        ->setThreadName('Weekly report: 2026-W42')
        ->setAppliedTags($reportsTagId),
);

$post->threadId;   // the new post

use Internet\InterCord\Attachment;

$chart = Attachment::fromPath('/tmp/latency.png', description: 'p99 latency, last 24 hours');

$webhook->execute(
    (new Payload())
        ->addEmbed((new RichEmbed())->setTitle('Latency')->setImage($chart->url()))
        ->addAttachment($chart)
        ->addAttachment(Attachment::fromString($csv, 'latency.csv'))
        ->addAttachment(Attachment::fromString($log, 'debug.log', spoiler: true)),
);

use Internet\InterCord\Component\ActionRow;
use Internet\InterCord\Component\LinkButton;

$webhook->execute(
    (new Payload())
        ->setContent('Release 4.2.0 is out.')
        ->addComponent(new ActionRow(
            new LinkButton('https://example.com/changelog', 'Changelog'),
            new LinkButton('https://example.com/download', 'Download', emoji: '⬇️'),
        )),
);

use Internet\InterCord\Component\Container;
use Internet\InterCord\Component\File;
use Internet\InterCord\Component\MediaGallery;
use Internet\InterCord\Component\MediaGalleryItem;
use Internet\InterCord\Component\Section;
use Internet\InterCord\Component\Separator;
use Internet\InterCord\Component\TextDisplay;
use Internet\InterCord\Component\Thumbnail;

$report = Attachment::fromPath('/tmp/report.pdf');

$webhook->execute(
    (new Payload())
        ->addComponent((new Container(
            new TextDisplay("## Weekly report\nAll services healthy."),
            new Section(
                new Thumbnail('https://example.com/uptime.png', 'Uptime chart'),
                new TextDisplay('**Uptime** 99.98%'),
                new TextDisplay('**Deploys** 14'),
            ),
            new Separator(),
            new MediaGallery(
                new MediaGalleryItem('https://example.com/latency.png', 'Latency'),
                new MediaGalleryItem('https://example.com/errors.png', 'Errors'),
            ),
            new File($report),
            new ActionRow(new LinkButton('https://example.com/dashboard', 'Dashboard')),
        ))->withAccentColor('#5865F2'))
        ->addAttachment($report),
);

$queue = $webhook->queued();

$queue->append('First');
$queue->append('Second');
$queue->prepend('Before everything');

$queue->run();      // send them all
$queue->run(1);     // or just the next one
$queue->deliver('Urgent');   // jump the queue and send now

$webhook = Webhook::fromUrl(
    $url,
    client: $psr18Client,    // any PSR-18 client; defaults to Guzzle with 10s connect / 30s total timeouts
    sleeper: $sleeper,       // an Internet\InterCord\Sleeper, to wait inside an event loop instead of usleep()
    maxRetries: 5,
);