Skip to content

Commit cd872fd

Browse files
committed
Sending carousels example
1 parent 0787acc commit cd872fd

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

README.md

+39
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,45 @@ The result:
789789

790790
![The result of sticker sending](./docs/31.png)
791791

792+
### Sending carousels
793+
794+
The driver also ships with implemented wrapper for attaching native carousel objects.
795+
796+
For example:
797+
798+
```php
799+
use BotMan\Drivers\VK\Extensions\VKKeyboardButton;
800+
use BotMan\Drivers\VK\Extensions\VKCarousel;
801+
use BotMan\Drivers\VK\Extensions\VKCarouselActionOpenLink;
802+
use BotMan\Drivers\VK\Extensions\VKCarouselElement;
803+
804+
$botman->hears('carousel', function($bot) {
805+
$carousel = new VKCarousel();
806+
807+
for($i = 1; $i <= 10; $i++){
808+
$carousel->addElements(
809+
new VKCarouselElement(
810+
"Element {$i}",
811+
"Description {$i}",
812+
[
813+
( new VKKeyboardButton() )
814+
->setColor("secondary")->setText("Button {$i}")->setValue("button1")
815+
],
816+
"-00000_11111", // This is an example icon ID:
817+
// replace `00000` with community ID, the `11111` - with image ID
818+
new VKCarouselActionOpenLink("https://some-url/")
819+
)
820+
);
821+
}
822+
823+
$bot->reply("Native carousel:", [
824+
"template" => $carousel->toJSON()
825+
]);
826+
});
827+
```
828+
829+
![Example result](./docs/32.png)
830+
792831
## See also
793832
- [VK documentation for developers](https://vk.com/dev/callback_api)
794833
- [New VK documentation for developers](https://dev.vk.com/)

docs/32.png

114 KB
Loading

0 commit comments

Comments
 (0)