File tree 2 files changed +39
-0
lines changed
2 files changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -789,6 +789,45 @@ The result:
789
789
790
790
![ The result of sticker sending] ( ./docs/31.png )
791
791
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
+
792
831
## See also
793
832
- [ VK documentation for developers] ( https://vk.com/dev/callback_api )
794
833
- [ New VK documentation for developers] ( https://dev.vk.com/ )
You can’t perform that action at this time.
0 commit comments