Last active
August 15, 2022 00:32
-
-
Save urigoren/be3190dd8a1d1d84994e1c066f2845b0 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
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