telegram-bot-sdk icon indicating copy to clipboard operation
telegram-bot-sdk copied to clipboard

Implement sending albums method

Open flaksp opened this issue 8 years ago • 7 comments
trafficstars

The new message type is album: https://telegram.org/blog/albums-saved-messages

Documentation for new method: https://core.telegram.org/bots/api#sendmediagroup

flaksp avatar Nov 15 '17 08:11 flaksp

👋 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.

welcome[bot] avatar Nov 15 '17 08:11 welcome[bot]

Its just released this morning. Give us a little bit of time to implement! 😂

jonnywilliamson avatar Nov 15 '17 13:11 jonnywilliamson

Is it supported now?

amediateam avatar May 01 '18 20:05 amediateam

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.

7KiLL avatar May 22 '18 12:05 7KiLL

Is it supported now? i need to send media group to telegram

please added this feature thank

honarkar98 avatar Jan 18 '19 02:01 honarkar98

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

halaei avatar Feb 12 '19 07:02 halaei

$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'),
]);

NikiforovAlexandr avatar Dec 24 '21 04:12 NikiforovAlexandr