Telegram-bot-sdk: Implement sending albums method

Created on 15 Nov 2017  路  6Comments  路  Source: irazasyed/telegram-bot-sdk

Most helpful comment

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.

All 6 comments

馃憢 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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

khalilst picture khalilst  路  3Comments

Enelar picture Enelar  路  3Comments

corneyl picture corneyl  路  3Comments

Visionary89 picture Visionary89  路  5Comments

iMohammadd picture iMohammadd  路  3Comments