PHP code example of californiamountainsnake / longmantelegrambot-inlinemenu

1. Go to this page and download the library: Download californiamountainsnake/longmantelegrambot-inlinemenu library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

californiamountainsnake / longmantelegrambot-inlinemenu example snippets



// Create your own Telegram class:
class MyTelegram extends InlineMenuTelegram
{

}

// somewhere in the webhook.php:
$telegram = new MyTelegram($bot_api_key, $bot_username);


$menu = new Menu('Top root menu', 'root', [
    [
        InlineButton::startCommand('Help!', 'help'),
        InlineButton::url('It\'s google', 'https://google.ru'),
    ],
    [
        InlineButton::toast('toast_identifier', 'Toast text!'),
        new Menu('Sub menu', 'submenu', [
            InlineButton::toast('sub_menu_toast', 'Submenu toast!'),
            InlineButton::menuSection('<< Back', Menu::path('root'))
        ]),
    ]
]);

// You must call this method once only on the your TOP level menu object.
$menu->buildPathsFromThisRoot();


class CallbackqueryCommand extends InlineMenuCallbackqueryCommand
{
    protected function getRootMenu(): Menu
    {
        // return the Menu object from the previous step
        return new Menu (...);
    }
}


$menu = new Menu (...);
$menu->buildPathsFromThisRoot();
$inlineKeyboard = $menu->getInlineKeyboard();

Request::sendMessage([
    'chat_id' => 'some_chat_id',
    'text' => 'This is menu!',
    'reply_markup' => $inlineKeyboard,
]);