Skip to content

Instantly share code, notes, and snippets.

@MikSDigital
Forked from urigoren/slack_and_telegram.php
Created November 27, 2018 20:21
Show Gist options
  • Save MikSDigital/8bc079257df03148cdea95fab9acd8cb to your computer and use it in GitHub Desktop.
Save MikSDigital/8bc079257df03148cdea95fab9acd8cb to your computer and use it in GitHub Desktop.
<?php
define('SLACK_WEBHOOK', 'https://hooks.slack.com/services/xxx/yyy/zzz');
function slack($txt) {
$msg = array('text' => $txt);
$c = curl_init(SLACK_WEBHOOK);
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
curl_setopt($c, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($c, CURLOPT_POST, true);
curl_setopt($c, CURLOPT_POSTFIELDS, array('payload' => json_encode($msg)));
curl_exec($c);
curl_close($c);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment