-
-
Save asimzeeshan/cfb179ed11a0ecb3e1d7ad45c6076ea3 to your computer and use it in GitHub Desktop.
PHP function for sending message to Telegram (using cURL)
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
function send2Telegram($id, $msg, $token = '', $silent = false) { | |
$data = array( | |
'chat_id' => $id, | |
'text' => $msg, | |
'parse_mode' => 'html', | |
'disable_web_page_preview' => true, | |
'disable_notification' => $silent | |
); | |
if($token != '') { | |
$ch = curl_init('https://api.telegram.org/bot'.$token.'/sendMessage'); | |
curl_setopt_array($ch, array( | |
CURLOPT_HEADER => 0, | |
CURLOPT_RETURNTRANSFER => 1, | |
CURLOPT_POST => 1, | |
CURLOPT_POSTFIELDS => $data | |
)); | |
$content = curl_exec($ch); | |
curl_close($ch); | |
} | |
return $content; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment