如何使用用户上传的 Telegram Bot API 下载全尺寸照片 [英] How to download full size photo using Telegram Bot API uploaded from user

查看:59
本文介绍了如何使用用户上传的 Telegram Bot API 下载全尺寸照片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个电报机器人,我需要下载用户发送给机器人的照片、音频和视频.使用 get file 方法返回的唯一路径,我只能得到一个缩略图.事实上,get file 方法的唯一结果包含一个非常小的文件大小值.我无法弄清楚问题出在哪里.照片通常以照片(而不是文件)的形式通过消息发送.

I'm working on a telegram bot and I need to download photo, audio, video sent by user to the bot. Using the only path returned by the get file method I only get a thumbnail. In fact the only result of the get file method contains a really tiny value for the file size. I can't figure out where the problem is. The photos are normally sent by message as photo (not as file).

推荐答案

首先你应该将带有这个 api 的照片下载到你的机器人

first you should download the photo with this api to your bot

https://api.telegram.org/bot<token>/getfile?file_id={the file_id of the photo you want to download}

然后它返回一个文件的响应,该文件具有名为 file_path 的属性

then it returns you a response of a File which has an attribute named file_path

然后使用file_path,您可以使用此下载全尺寸照片

then using the file_path you can download the photo full size using this

https://api.telegram.org/file/bot<token>/<file_path>

所有这些都基于此处找到的官方文档.Telegram API 文档

all of this is based on official documentation found here . Telegram API Doc

这篇关于如何使用用户上传的 Telegram Bot API 下载全尺寸照片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆