telegram-bot-sdk
telegram-bot-sdk copied to clipboard
Implement sending albums method
The new message type is album: https://telegram.org/blog/albums-saved-messages
Documentation for new method: https://core.telegram.org/bots/api#sendmediagroup
👋 Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you include steps to reproduce it. We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.
To help make it easier for us to investigate your issue, please follow the contributing guidelines.
Its just released this morning. Give us a little bit of time to implement! 😂
Is it supported now?
public function sendMediaGroup()
{
$media[0] = [
'type' => 'photo',
'media'=> 'URL1'
];
$media[1] = [
'type' => 'photo',
'media'=> 'URL2'
];
$json = json_encode($media);
$params = [
'chat_id' => <CHAT_ID>,
'media' => $json
];
$url = 'https://api.telegram.org/bot<YOUR_TOKEN>/sendMediaGroup?';
$url = $url.http_build_query($params);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_exec($ch);
curl_close($ch);
}
Fast implementation.
Is it supported now? i need to send media group to telegram
please added this feature thank
For sendMediaGroup() support, there is a need to refactor the way this package handle files. I have done that in my fork, but the fork is deviated from this one and I don't think it can be easily merged, because I removed some features as well.
$telegram->sendMediaGroup([
'chat_id' => getenv('CHAT_ID'),
'media' => [
new InputMedia([
'type' => 'photo',
'media' => fopen(__DIR__.'/files/photo1.png', 'rb'),
'caption' => 'Test 1',
]),
new InputMedia([
'type' => 'photo',
'media' => fopen(__DIR__.'/files/photo2.png', 'rb'),
'caption' => 'Test 2'
]),
],
]);
If you are still interested, please check https://github.com/halaei/telegram-bot
$api->sendMediaGroup([
'chat_id' => -1,
'media' => json_encode([
[
'type' => 'photo',
'media' => 'attach://file1.jpg'
],
[
'type' => 'photo',
'media' => 'attach://file2.jpg'
]
]),
'file1.jpg'=> InputFile::create('./file1.jpg'),
'file2.jpg'=> InputFile::create('./file2.jpg'),
]);