PHP code example of meqy / vkrinochka

1. Go to this page and download the library: Download meqy/vkrinochka 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/ */

    

meqy / vkrinochka example snippets



$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();



$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!");
});



$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");
});