I’m trying some Google Apps Script script for telegram bot API.
var token = "BOT:TOKEN";
var telegramUrl = "https://api.telegram.org/bot" + token;
var chat_id = "CHAT_ID";
var image1 = "https://telegram.org/img/t_logo.png";
var image2 = "https://www.gstatic.com/images/branding/product/2x/apps_script_48dp.png";
var data = {
method: "post",
payload: {
"method": "sendMediaGroup",
"chat_id": chat_id,
"media": [
{"type": "photo", "media": image1},
{"type": "photo", "media": image2},
]
}
}
UrlFetchApp.fetch('https://api.telegram.org/bot' + token + '/', data);
}
Telegram Bot API Docs said that media type is an Array of InputMediaPhoto
. But I dont understand. Could anyone help me an example of inputMediaPhoto
for sending group of photos use sendMediaGroup method?
I did try method sendPhoto
https://core.telegram.org/bots/api#sendphoto, it worked. Now i need to send group of photos.
2
Answers
From your replying comments, I could confirm the following situation.
token
can be used.{"ok":false,"error_code":400,"description":"Bad Request: can't parse media JSON object"}
From above situation, I thought that the request body might be required to be sent as JSON. So how about the following modification?
Modified script:
From:
To:
Reference:
Recently, I need to send group photos into Telegram using Telegram Bot API and couldn’t figure out much and have land on this page. Getting some idea from @Tanaike and debug through @pyTelegramBotAPI, I have done some Python code that will send local files to Telegram as group photos. So, I just wanted to share it here to benefit people who facing the same problem.