Answer the question
In order to leave comments, you need to log in
How to solve the problem with sending the keyboard?
There is this code:
public function sendMessage($user_id, $message, $keyboard = null) {
if (!is_null($keyboard)) {
return $this->params("messages.send", [
"message" => $message,
"peer_id" => $user_id,
"random_id" => 0,
"keyboard" => $keyboard
]);
}
else {
$this->params("messages.send", [
"message" => $message,
"peer_id" => $user_id,
"random_id" => 0
]);
}
}
public function buttonText($text, $color, $payload) {
$button = [
"action" => [
"type" => "text",
"payload" => '{
"command": '.$payload.'
}',
"label" => $text
],
"color" => $color
];
}
public function getKeyboard($buttons = [], $one_time = false) {
$keyboard = [
"one_time" => $one_time,
"buttons" => [
$buttons
]
];
return json_encode($keyboard, JSON_UNESCAPED_UNICODE);
}
$button1 = $request->buttonText("Кнопка 1", "secondary", "button1");
$button2 = $request->buttonText("Кнопка 2", "secondary", "button2");
$keyboard = $request->getKeyboard();
$request->sendMessage($user_id, "Message", $keyboard);
//$request is a class interpreter, what make a query to vk api
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question