Postman-JSON序列化数组中的电报bot sendMediaGroup()?

Postman-JSON序列化数组中的电报bot sendMediaGroup()?,postman,telegram,telegram-bot,Postman,Telegram,Telegram Bot,我正在使用Postman应用程序与电报机器人api进行交互。我使用sendPhoto()方法发送了照片,如下所示: https://api.telegram.org/botToken/sendPhoto?chat_id=00000000&photo=AgAC***rgehrehrhrn { "chat_id": 777000, "media": [ { "type": "photo&quo

我正在使用Postman应用程序与电报机器人api进行交互。我使用sendPhoto()方法发送了照片,如下所示:

https://api.telegram.org/botToken/sendPhoto?chat_id=00000000&photo=AgAC***rgehrehrhrn
{
  "chat_id": 777000,
  "media": [
    {
      "type": "photo",
      "media": "https://example.com/first_photo_url.png",
      "caption": "an optional description of the first photo",
      "parse_mode": "optional (you can delete this parameter) the parse mode of the caption"
    },
    {
      "type": "photo",
      "media": "https://example.com/fsecond_photo_url.png",
      "caption": "an optional description of the second photo",
      "parse_mode": "optional (you can delete this parameter) the parse mode of the caption"
    }
  ],
}
但是我不理解sendMediaGroup()方法。是否有人可以发布一个示例,说明如何编写https字符串以发送两张照片?
谢谢

您需要在url
https://api.telegram.org/botToken/sendPhoto
带有JSON正文。您正在使用url指定请求的所有参数,但url的长度仅为个字符。相反,POST请求的主体在大小方面没有限制。JSON正文应该如下所示:

https://api.telegram.org/botToken/sendPhoto?chat_id=00000000&photo=AgAC***rgehrehrhrn
{
  "chat_id": 777000,
  "media": [
    {
      "type": "photo",
      "media": "https://example.com/first_photo_url.png",
      "caption": "an optional description of the first photo",
      "parse_mode": "optional (you can delete this parameter) the parse mode of the caption"
    },
    {
      "type": "photo",
      "media": "https://example.com/fsecond_photo_url.png",
      "caption": "an optional description of the second photo",
      "parse_mode": "optional (you can delete this parameter) the parse mode of the caption"
    }
  ],
}
有关更多信息,请参阅:


电报API的方法。

必须将JSON作为字符串或序列化JSON发送到电报API。格式与@gioiaca9的答案相同

注意:仅显示第一幅图像中的标题

试试这段Python代码

def发送照片(api密钥、聊天id、照片路径):
参数={
“聊天id”:聊天id,
“媒体”:[],
}
对于照片路径中的路径:
params['media'].append({'type':'photo','media':path})
params['media']=json.dumps(params['media'])
url=f'https://api.telegram.org/bot{api_key}/sendMediaGroup'
return requests.post(url,data=params)
如果uuuu name uuuuuu='\uuuuuuu main\uuuuuuu':
发送照片('your_key','yourchannel',['http://your.image.one', 'http://your.image.two'])