meqy / vkrinochka
PHP Library for a easly calling to VkApi
1.0.1
2020-06-20 13:40 UTC
Requires
- ext-curl: *
- ext-json: *
This package is auto-updated.
Last update: 2024-09-21 02:10:26 UTC
README
VkRinochka is a library for working with VKApi
Download
composer require meqy/vkrinochka=1.0.1
Examples
Simple example
<?php $access_token = ""; $confirmation_code = 1; $vk = new \vkrinochka\vkrinochka\Vk([ "access_token" => $access_token, "confirmation_code" => $confirmation_code ]); $vk->bot->hear("/hello/iu", function ($context){ $context->reply("Hello!"); }); $vk->bot->start();
Handle keyboard payload
<?php $access_token = ""; $confirmation_code = 1; $vk = new \vkrinochka\vkrinochka\Vk([ "access_token" => $access_token, "confirmation_code" => $confirmation_code ]); $vk->bot->hear(function ($val, $context) { return $context->getData()->getPayload()->command == "start"; }, function ($context){ $context->reply("Hello!"); });
Call Vk methods and get matched array
<?php $access_token = ""; $confirmation_code = 1; $vk = new \vkrinochka\vkrinochka\Vk([ "access_token" => $access_token, "confirmation_code" => $confirmation_code ]); $vk->bot->hear("/getName (\d+)/iu", function ($context) use ($vk) { $user = $vk ->method("users.get", ["user_ids" => $context->matched[1]])["items"][0]["first_name"]; $context ->reply("You search name of this user? - $user"); });
Future
- Add LongPolling
- Refactoring for code
- Add static typing for all variables