gpt4 book ai didi

telegram-bot - 电报机器人通过 URL 发送照片返回 "Bad Request: wrong file identifier/HTTP URL specified"

转载 作者:行者123 更新时间:2023-12-04 12:01:12 42 4
gpt4 key购买 nike

我正在我的 Telegram 机器人中通过 url 发送照片。对于某些照片,我收到来自 Telegram 的错误消息:

{"ok":false,"error_code":400,"description":"Bad Request: wrong file identifier/HTTP URL specified"}

例如:
发送 this摄影作品:
https://api.telegram.org/bot<BOT_KEY>/sendPhoto?chat_id=<CHAT_ID>&photo=https%3A%2F%2Fdrscdn.500px.org%2Fphoto%2F153590277%2Fq%253D80_m%253D2000%2Fv2%3Fwebp%3Dtrue%26sig%3D8b429a27872dfdb4f68ddc5edd488ce9e6a57977415fa323178cd62c5100a3ff

但是 this文件奇怪地不起作用:
https://api.telegram.org/bot<BOT_KEY>/sendPhoto?chat_id=<CHAT_ID>&photo=https%3A%2F%2Fdrscdn.500px.org%2Fphoto%2F247611167%2Fq%253D80_m%253D1500%2Fv2%3Fwebp%3Dtrue%26sig%3Dcfa117f225962250323c1202797abe8d45b47d59da12d780f4bf5231687c4331

请注意,对于这两个示例:
  • URL 有效
  • MIME 类型似乎没问题(两者实际上都是 jpg 文件)
  • 文件大小小于 10 MB

  • 难道我做错了什么?或者对这个问题有什么想法?

    谢谢,

    最佳答案

    可能的解决方案:
    将具有随机值的无用属性添加到文件 url 并重试,直到成功。
    我也遇到了这个问题。我刚刚发现具有几乎相同 url 的几乎相同的文件具有不同的行为。它让我震惊。我不认为这是我的文件的错,所以我通过添加一个无用的属性并调整其值来修改文件 url。重试了很多次,成功了!
    您可以通过运行此代码段来尝试一下。唯一的区别是 &random=58&random=64在每个文件 url 的末尾。

    <h5>Your Bot Token</h5>
    <input id="token" type="text" style="width: 400px;" value="{YourBotToken}" />

    <h3>200 OK Example</h3>
    <form action="https://api.telegram.org/bot{YourBotToken}/sendPhoto" method="POST" enctype="application/x-www-form-urlencoded">
    <textarea type="text/html" name="photo" rows="4" cols="70" readonly="readonly">http://api.map.baidu.com/staticimage?center=140.50,36.15&width=1024&height=576&zoom=6&amp;copyright=1&markers=140.50,36.15&markerStyles=l&random=58</textarea>
    <input type="text" name="chat_id" value="@{YourChatID}" />
    <input type="submit" value="Submit" onclick="this.form.action='https://api.telegram.org/bot'+document.getElementById('token').value+'/sendPhoto';" />
    </form>
    <br><br>
    <h3>400 Bad Request Example</h3>
    <form action="https://api.telegram.org/bot{YourBotToken}/sendPhoto" method="POST" enctype="application/x-www-form-urlencoded">
    <textarea type="text/html" name="photo" rows="4" cols="70" readonly="readonly">http://api.map.baidu.com/staticimage?center=140.50,36.15&width=1024&height=576&zoom=6&amp;copyright=1&markers=140.50,36.15&markerStyles=l&random=64</textarea>
    <input type="text" name="chat_id" value="@{YourChatID}" />
    <input type="submit" value="Submit" onclick="this.form.action='https://api.telegram.org/bot'+document.getElementById('token').value+'/sendPhoto';" />
    </form>

    关于telegram-bot - 电报机器人通过 URL 发送照片返回 "Bad Request: wrong file identifier/HTTP URL specified",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49645510/

    42 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com