Answer the question
In order to leave comments, you need to log in
Why does the telegram bot see only a part of the conversations in which it was added?
Tell me why the telegram bot sees only a part of the conversations to which it was added, and not all?
here is the code to get it:
public function getChats()
{
$token = $_ENV['TOKEN'];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.telegram.org/bot'. $token .'/getUpdates');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
$headers = array();
$headers[] = 'Content-Type: application/json';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = json_decode(curl_exec($ch), true);
if (curl_errno($ch)) {
return new JsonResponse(['message:' . curl_error($ch)]);
}
curl_close($ch);
$elements = array();
$chats = [];
foreach ($result['result'] as $chat) {
if (in_array(@$chat['message']['chat']['title'], $elements))
continue;
else
$elements[] = @$chat['message']['chat']['title'];
$chats[] = @$chat['message']['chat'];
}
return $chats;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question