public function Webhook::sendMessage in Fastly 7.2
Sends request to WebHookURL
Parameters
$message:
$type:
Return value
mixed
File
- ./
fastly.webhook.inc, line 16
Class
- Webhook
- Class Webhook.
Code
public function sendMessage($message, $type, $action = null) {
global $base_url;
$headers = array(
'Content-type: application/json',
);
$data = json_encode(array(
"text" => $base_url . " // " . $type . ': ' . $message,
"username" => "fastly-drupal-bot",
"icon_emoji" => ":airplane:",
));
$options = array(
"method" => "POST",
"data" => $data,
"connect_timeout" => 15,
"headers" => $headers,
);
$webhookUrl = variable_get('fastly_webhook_url');
$webhookActions = variable_get('fastly_webhook_events');
if (in_array($action, $webhookActions)) {
drupal_http_request($webhookUrl, $options);
}
}