【问题标题】:Send a photo from php url in telegram bot在电报机器人中从 php url 发送照片
【发布时间】:2021-02-10 07:16:24
【问题描述】:

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

【问题讨论】:

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


    【解决方案1】:

    没关系,我设法保存文件并上传

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

    【讨论】:

      猜你喜欢
      • 2016-10-17
      • 1970-01-01
      • 1970-01-01
      • 2016-08-15
      • 2021-04-20
      • 1970-01-01
      • 2016-06-29
      • 1970-01-01
      • 2020-07-09
      相关资源
      最近更新 更多