You are here

function _slack_send_message in Slack 6

Same name and namespace in other branches
  1. 7 includes/slack.api.inc \_slack_send_message()

Send message to the Slack with more options.

Parameters

string $team_name: Your team name in the Slack

string $team_token: The token from "Incoming WebHooks" integration in the Slack

string $message: The message sent to the channel

array $message_options: An associative array, it can contain:

  • channel: The channel in the Slack service to send messages
  • username: The bot name displayed in the channel

Return value

object Can contain: success fail fail

  • data: ok No hooks Invalid channel specified
  • status message: OK Not found Server Error
  • code: 200 404 500
  • error: - Not found Server Error
1 call to _slack_send_message()
slack_send_message in includes/slack.api.inc
Send message to the Slack.

File

includes/slack.api.inc, line 65
Slack integration module API functions.

Code

function _slack_send_message($webhook_url, $message, $message_options = array()) {
  $headers = array(
    'Content-Type' => 'application/x-www-form-urlencoded',
  );
  $message_options['text'] = $message;
  $sending_data = 'payload=' . drupal_to_js($message_options);
  $result = drupal_http_request($webhook_url, $headers, 'POST', $sending_data);
  return $result;
}