PHP code example of sally / vk-keyboard
1. Go to this page and download the library: Download sally/vk-keyboard 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/ */
sally / vk-keyboard example snippets
ally\VkKeyboard\Facade;
use Sally\VkKeyboard\Contracts\Keyboard\Button\FactoryInterface;
use Sally\VkKeyboard\Object\Keyboard\Button\Text;
$keyboard = Facade::createKeyboardBasic(function (FactoryInterface $factory) {
return [
[
$factory->location([]),
],
[
$factory->text('Текстовая кнопка', ['button' => 1], Text::COLOR_RED),
$factory->link('Кнопка с ссылкой', 'https://github.com/Sally-Framework/vk-keyboard', []),
],
[
$factory->pay('action=transfer-to-group&group_id=1&aid=10')
],
[
$factory->app('Кнопка приложения', 6979558, '-181108510', 'sendKeyboard')
]
];
});
ally\VkKeyboard\Facade;
use Sally\VkKeyboard\Contracts\Keyboard\Button\FactoryInterface;
use Sally\VkKeyboard\Object\Keyboard\Button\Text;
$keyboard = Facade::createKeyboardInline(function (FactoryInterface $factory) {
return [
[
$factory->location([]),
],
[
$factory->text('Текстовая кнопка', ['button' => 1], Text::COLOR_RED),
$factory->link('Кнопка с ссылкой', 'https://github.com/Sally-Framework/vk-keyboard', []),
],
[
$factory->pay('action=transfer-to-group&group_id=1&aid=10')
],
[
$factory->app('Кнопка приложения', 6979558, '-181108510', 'sendKeyboard')
]
];
});
ally\VkKeyboard\Facade;
use Sally\VkKeyboard\Contracts\Keyboard\Button\FactoryInterface as ButtonFactoryInterface;
use Sally\VkKeyboard\Contracts\Template\Carousel\Element\FactoryInterface as CarouselElementInterface;
$templateWithOpenPhoto = Facade::createCarousel(function (CarouselElementInterface $elementFactory, ButtonFactoryInterface $buttonFactory) {
return [
$elementFactory->openPhoto([
$buttonFactory->location(['button' => 'location']),
$buttonFactory->pay('action=transfer-to-group&group_id=1&aid=10'),
$buttonFactory->link('Кнопка с ссылкой', 'https://github.com/Sally-Framework/vk-keyboard', []),
], 'Карусель Open Photo', 'По нажатию у вас откроется картинка', '-109837093_457242809'),
$elementFactory->openPhoto([
$buttonFactory->location(['button' => 'location']),
$buttonFactory->pay('action=transfer-to-group&group_id=1&aid=10'),
$buttonFactory->link('Кнопка с ссылкой', 'https://github.com/Sally-Framework/vk-keyboard', []),
], 'Карусель Open Photo', 'По нажатию у вас откроется картинка', '-109837093_457242809'),
$elementFactory->openPhoto([
$buttonFactory->location(['button' => 'location']),
$buttonFactory->pay('action=transfer-to-group&group_id=1&aid=10'),
$buttonFactory->link('Кнопка с ссылкой', 'https://github.com/Sally-Framework/vk-keyboard', []),
], 'Карусель Open Photo', 'По нажатию у вас откроется картинка', '-109837093_457242809'),
];
});