Created
February 3, 2019 20:52
-
-
Save mchaisse/63f0ebc08bfc109574e7a93031b9ba42 to your computer and use it in GitHub Desktop.
Synology - Slack Notifications
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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