从电报bot中的php url发送照片

时间:2020-10-27 22:57:19

标签: python telegram telegram-bot python-telegram-bot telepot

我正在尝试使用带电报api的sendPhoto方法(https://core.telegram.org/bots/api#sendphoto)通过电报机器人发送照片,但它仅接受.jpg,.jpeg .gif,.png,.tif或.bmp,我要使用的照片通过.php网址显示。我如何设法获得有效的网址?我也可以使用multipart / form-data上载它,但是它不起作用。

1 个答案:

答案 0 :(得分:0)

没关系,我设法做到了保存文件并使用

上传
urllib.request.urlretrieve("link.php", "./file.png")
bot.sendPhoto(chat_id, photo=open('./file.png', 'rb'))