Eleirbag89 / TelegramBotPHP

A very simple PHP Telegram Bot API for sending messages.
http://eleirbag89.github.io/TelegramBotPHP
MIT License
807 stars 341 forks source link

how to send media group? #186

Closed honarkar98 closed 4 years ago

Mohsen322 commented 5 years ago

first check the documentation https://core.telegram.org/bots/api#sendmediagroup

persian tutorial: https://virgool.io/@mohsen322/how-to-send-pictures-as-a-album-via-telegram-bot-x3z46dtsvxeh

sample:

$media = array (

    array('type' => 'photo', 'media' => 'PIC_URL1', 'caption' => 'pic 1'),

    array('type' => 'photo', 'media' => 'PIC_URL2', 'caption' => 'pic 2'),

    array('type' => 'photo', 'media' => 'PIC_URL3', 'caption' => 'pic 3')

);

$content = array('chat_id' => $chat_id, 'media' => json_encode($media));

$telegram->sendMediaGroup($content);
SM-hosseini commented 4 years ago

add this code to Telegram.php:

public function sendMediaGroup(array $content)
{
        return $this->endpoint('sendmediagroup', $content);
}

and use like this code:

$media = array (

    array('type' => 'photo', 'media' => 'PIC_URL1', 'caption' => 'pic 1'),

    array('type' => 'photo', 'media' => 'PIC_URL2', 'caption' => 'pic 2'),

    array('type' => 'photo', 'media' => 'PIC_URL3', 'caption' => 'pic 3')

);

$content = array('chat_id' => $chat_id, 'media' => json_encode($media));

$telegram->sendMediaGroup($content);