Skip to content
This repository has been archived by the owner on Dec 17, 2018. It is now read-only.

Latest commit

 

History

History
34 lines (24 loc) · 1.27 KB

chat-post-message.md

File metadata and controls

34 lines (24 loc) · 1.27 KB

chat.postMessage

This method posts a message to a channel.

Official documentation https://api.slack.com/methods/chat.postMessage
Payload class ChannelsArchivePayload
PayloadResponse class ChannelsArchivePayloadResponse

Usage

$apiClient = new ApiClient('your-slack-token-here');

$payload = new ChatPostMessagePayload();
$payload->setChannel('#general');
$payload->setMessage('Hello world!');

$response = $apiClient->send($payload);

if ($response->isOk()) {
    // message has been posted
} else {
    // something went wrong, but what?
    
    // simple error (Slack's error message)
    echo $response->getError();
    
    // explained error (Slack's explanation of the error, according to the documentation)
    echo $response->getErrorExplanation();
}