J
J
jazzman72021-06-30 14:05:02
Telegram
jazzman7, 2021-06-30 14:05:02

Telegram api does not send .doc, how to fix?

hello, there is a code that sends alerts and messages, but for some reason not all files are sent through this code. pdf flies, mp3 flies, jpg flies, doc(x) does not fly. How to fix it?

$ch = curl_init();
    curl_setopt_array(
        $ch,
        array(
              CURLOPT_URL => 'https://api.telegram.org/bot' . TELEGRAM_TOKEN . '/sendDocument',
            CURLOPT_POST => TRUE,
            CURLOPT_RETURNTRANSFER => TRUE,
            CURLOPT_TIMEOUT => 10,
            CURLOPT_POSTFIELDS => array(
                'chat_id' => TELEGRAM_CHATID,
                'caption' => $msg,
                'document' => $ooo
            ),
        )
    );
    curl_exec($ch);

Answer the question

In order to leave comments, you need to log in

2 answer(s)
X
xCodeError, 2021-06-30
@xCodeError

What is the error in the answer?

A
Alexey, 2021-11-03
@olololollloo

'document' => $ooo
how can you guess what you have in this variable $ooo ?
read the documentation:
In sendDocument , sending to a URL currently only works for GIF , PDF and ZIP files.
Personally, I don’t want to use url and pdf,
zip jpg mp4 is normal
I solved the problem like this:
"chat_id" => $chat_id,
"caption" => "signature",
"document" => new CURLFile(realpath(__DIR__.'/1 .pdf'))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question