Skip to content

Instantly share code, notes, and snippets.

@mchaisse
Created February 3, 2019 20:52
Show Gist options
  • Save mchaisse/63f0ebc08bfc109574e7a93031b9ba42 to your computer and use it in GitHub Desktop.
Save mchaisse/63f0ebc08bfc109574e7a93031b9ba42 to your computer and use it in GitHub Desktop.
Synology - Slack Notifications
<?php
$msg = 'Test';
parse_str($_SERVER['QUERY_STRING'], $output);
if ($output['token'] != 'TOKEN') {
exit();
}
$msg = $output['message'];
$webhook_url = $output['webhook'];
$slack_webhook = 'https://hooks.slack.com/services/'.$webhook_url;
$message = array('payload' => json_encode(array('text' => $msg)));
$c = curl_init($slack_webhook);
curl_setopt($c, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($c, CURLOPT_POST, true);
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
curl_setopt($c, CURLOPT_POSTFIELDS, $message);
curl_exec($c);
curl_close($c);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment