Maknz\Slack\Client::sendMessage PHP Method

sendMessage() public method

Send a message.
public sendMessage ( Message $message ) : void
$message Message
return void
    public function sendMessage(Message $message)
    {
        $payload = $this->preparePayload($message);
        $encoded = json_encode($payload, JSON_UNESCAPED_UNICODE);
        if ($encoded === false) {
            throw new RuntimeException(sprintf('JSON encoding error %s: %s', json_last_error(), json_last_error_msg()));
        }
        $this->guzzle->post($this->endpoint, ['body' => $encoded]);
    }

Usage Example

Example #1
0
 /**
  * Send the message
  *
  * @param string $text The text to send
  * @return void
  */
 public function send($text = null)
 {
     if ($text) {
         $this->setText($text);
     }
     $this->client->sendMessage($this);
 }
All Usage Examples Of Maknz\Slack\Client::sendMessage