I'm using the Telegram API to send error logs to my applications.
I display some key information, but I would also like to display the trace
of the exception. The problem is that the Telegram returns a 400
error, showing that the value exceeds the maximum size (which is 4096 if I'm not mistaken).
In this case, I wanted to continue displaying the main log information and add this snippet of trace
of the exception (which is large) in a txt
file.
Would it be possible, in addition to sending the message, to attach a text file together?
The code I have is the following:
function telegram_log($chat_id, $text, $parse_mode = 'markdown')
{
$cli = new \GuzzleHttp\Client([
'base_url' => TELEGRAM_URL_API,
]);
$response = $cli->post('sendMessage', [
'query' => compact('text', 'parse_mode', 'chat_id'),
'timeout' => 5,
'connect_timeout' => 5,
]);
return json_decode( (string) $response->getBody() );
}