Skip to content

Instantly share code, notes, and snippets.

@urigoren
Last active August 15, 2022 00:32
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save urigoren/be3190dd8a1d1d84994e1c066f2845b0 to your computer and use it in GitHub Desktop.
Save urigoren/be3190dd8a1d1d84994e1c066f2845b0 to your computer and use it in GitHub Desktop.
<?php
define('SLACK_WEBHOOK', 'https://hooks.slack.com/services/xxx/yyy/zzz');
define('TELEGRAM_BOT_TOKEN', '...');
define('TELEGRAM_CHAT_ID', '12345');
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);
}
function telegram($txt) {
$url = "https://api.telegram.org/bot".TELEGRAM_BOT_TOKEN."/sendMessage";
$msg = array('text' => $txt);
$c = curl_init($url);
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('text' => $txt, 'chat_id'=>TELEGRAM_CHAT_ID));
curl_exec($c);
curl_close($c);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment