از این فانکشن ها برای ارسال پیام استفاده کنید
function bot($method, $data = [])
{
$url = "https://api.telegram.org/bot" . API_TOKEN . "/" . $method;
$options = [
'http' => [
'method' => 'POST',
'header' => "Content-Type: application/x-www-form-urlencoded\r\n",
'content' => http_build_query($data),
'ignore_errors' => true
]
];
$context = stream_context_create($options);
return json_decode(
file_get_contents($url, false, $context),
true
);
}
function message($chat_id, $msg, $markup = null, $reply_to_message_id = null)
{
$msg = urldecode($msg);
return bot('sendMessage', [
'chat_id' => $chat_id,
'text' => $msg,
'disable_web_page_preview' => true,
'reply_markup' => $markup,
'parse_mode' => 'HTML',
'reply_to_message_id' => $reply_to_message_id
]);
}