How can the telegram bot receive the file_file of the downloaded file?

In the telegram API documentation, I see: "You can pass file_id as a String to resend a photo that is already on Telegram servers," but I can’t find ways to get file_id from the downloaded file. How can i get it?

+4
source share
4 answers

Depending on the method (file type) that you have chosen to send the file, after sending the file to Telegram, a response is returned. For example, if you send an MP3 file to Telegram using the method sendAudio, Telegram returns an object Audiothat contains the file identifier. Source: https://core.telegram.org/bots/api#audio

+2
source

It depends on your content_types, for example:

Video:

message.video.file_id

Audio:

message.audio.file_id

Photo:

message.photo[2].file_id

See this link for more details .

+2
source

, Message PhotoSize

https://core.telegram.org/bots/api#photosize

, file_id, , sendPhoto.

, Update - , Message, , , Chat id , , PhotoSize ( PHP , ...)

$update->message->photo - . - For, , , 1.

file_id string sendPhoto photo chat_id.

, !

P.S. API, , !

+1

, , , , https://api.telegram.org/bot'.BOT_TOKEN.'/getUpdates , . Json Json :

{
    "update_id" = 1111111,
    "message" =
        {
            "message_id" = 1111111,
            "from" =
                {
                    "id" = 111111,
                    ...
                }
            "chat" =
                {
                "id" = 111111,
                ...
                }
            "date" = 111111,
            "photo" = 
                {
                    {
                        "file_id" = HERE IS YOU FILE ID 1,
                        "file_size" => XXXX,
                        "width" => XX,
                        "height" => XX,
                    }
                }
        }
}
0
source

All Articles