Basic Usage

Send a Message

Advanced Usage

Legacy WebHook URLs

Early versions of Incoming Webhooks used a generic webhook path for all teams. If your webhook URL starts with something like myteam.slack.com, give Phlack your team name and Incoming Webhook token, and it will do the rest:

Messages

Creating Messages

Messages can be created using the provided builders, or they can be instantiated directly.

Message Builder

The MessageBuilder allows for programmatic creation of a Message object.

<?php// ...$messageBuilder=$phlack->getMessageBuilder();$messageBuilder->setText('I was created in the MessageBuilder')->setChannel('testing')->setIconEmoji('ghost');$message=$messageBuilder->create();

You can also use the MessageBuilder directly to create the Message object and add Attachments. The MessageBuilder supports method chaining to allow for adding multiple Attachment objects to a single message.

Attachment Builder

<?php// ...// Get the AttachmentBuilder$attachmentBuilder=$phlack->getAttachmentBuilder();// Create the Attachment$attachment=$attachmentBuilder->setTitle('My Attachment Title')->setTitleLink('http://www.example.com')->setPretext('Some optional pretext')->setText('This is the body of my attachment')->setColor($color)->addField('Field 1', 'Some Value', true)->setFallback($title.''.$pretext)->create();// Create a Message to contain the Attachment$message=new\Crummy\Phlack\Message\Message('This message contains an attachment.');// Add the Attachment to the Message$message->addAttachment($attachment);

Resource Iterators

Example: ListFilesIterator

The ListFilesIterator eases the ability to iterate through multiple pages of data from the Slack API. Using the iterator eliminates the need to manually call the API multiple times to retrieve all pages of the result set.