Answer the question
In order to leave comments, you need to log in
How to send a message to a user from a telegram bot?
How to send a message to a user from a telegram bot?
the bot has been added to the contact list, how can I send a message from the bot now?
Well, like
Hello Vasya, my name is Bot Ivanovich, it's 12:04, I need to go to lunch.
ps. meaning POST or GET request
Answer the question
In order to leave comments, you need to log in
function sendMessage($chatId, $message, $token)
{
$url = "https://api.telegram.org/{$token}/sendMessage?" . http_build_query([
'chat_id' => $chatId,
'text' => $message
]);
$ch = curl_init();
$optArray = [
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true
];
curl_setopt_array($ch, $optArray);
curl_exec($ch);
curl_close($ch);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question