Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example 6.1 error #88

Open
error1001es opened this issue Jul 28, 2020 · 3 comments
Open

Example 6.1 error #88

error1001es opened this issue Jul 28, 2020 · 3 comments

Comments

@error1001es
Copy link

error1001es commented Jul 28, 2020

Example 6.1

`Warning: Declaration of CallbackApiMyHandler::messageNew($object) should be compatible with VK\CallbackApi\VKCallbackApiHandler::messageNew(int $group_id, ?string $secret, array $object) in on line 17

Warning: Declaration of CallbackApiMyHandler::wallPostNew($object) should be compatible with VK\CallbackApi\VKCallbackApiHandler::wallPostNew(int $group_id, ?string $secret, array $object) in on line 21
PHP Warning: Declaration of CallbackApiMyHandler::messageNew($object) should be compatible with VK\CallbackApi\VKCallbackApiHandler::messageNew(int $group_id, ?string $secret, array $object) in on line 17
PHP Warning: Declaration of CallbackApiMyHandler::wallPostNew($object) should be compatible with VK\CallbackApi\VKCallbackApiHandler::wallPostNew(int $group_id, ?string $secret, array $object) in on line 21`
code:

`require 'vendor/autoload.php';

const ACCESS_TOKEN = '*';

const GROUP_ID = *;

$vk = new VK\Client\VKApiClient();
$vk->groups()->setLongPollSettings(ACCESS_TOKEN, [
'group_id' => GROUP_ID,
'enabled' => 1,
'message_new' => 1,
'wall_post_new' => 1,
]);

class CallbackApiMyHandler extends VK\CallbackApi\VKCallbackApiHandler {
public function messageNew($object) {
echo 'New message: ' . $object['body'];
}

public function wallPostNew($object) {
    echo 'New wall post: ' . $object['text'];
}

}

$handler = new CallbackApiMyHandler();
$executor = new VK\CallbackApi\LongPoll\VKCallbackApiLongPollExecutor($vk, ACCESS_TOKEN, GROUP_ID, $handler, 25);
$executor->listen();`

@SlFomin
Copy link

SlFomin commented Sep 18, 2020

@error1001es ошибка прямым текстом указана, ваши методы должны быть совместимы с теми что описаны в VK\CallbackApi\VKCallbackApiHandler

@SlFomin
Copy link

SlFomin commented Sep 18, 2020

если там messageNew(int $group_id, ?string $secret, array $object), то и у вас функция должна быть описана совместимым образом, а у вас принимается только $object, не указаны типы и кол-во аргументов другое...

@error1001es
Copy link
Author

если там messageNew(int $group_id, ?string $secret, array $object), то и у вас функция должна быть описана совместимым образом, а у вас принимается только $object, не указаны типы и кол-во аргументов другое...

это ошибка при подключении библиотеки, а не при использовании её методов

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants