VkRinochka is a library for working with VKApi
composer require meqy/vkrinochka=1.0.1
<?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();
<?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!");
});
<?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");
});
- Add LongPolling
- Refactoring for code
- Add static typing for all variables