Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if (!isset($_REQUEST)){
- return;
- }
- $confirmationToken = ''; // Токен подтверждения
- $token = ''; // Токен сообщества
- $secretKey = ''; // Секретная фраза
- $data = json_decode(file_get_contents('php://input'));
- if (strcmp($data->secret, $secretKey) !== 0) {
- return;
- }
- function getBtn($label, $color, $payload = '')
- {
- return [
- 'action' => [
- 'type' => 'text',
- "payload" => json_encode($payload, JSON_UNESCAPED_UNICODE),
- 'label' => $label
- ],
- 'color' => $color
- ];
- }
- switch ($data->type)
- {
- case 'confirmation':
- die($confirmationToken);
- break;
- case 'message_new':
- $userID = $data->object->from_id;
- $userMsg = $data->object->text;
- if ($userMessage == "Привет")
- {
- $keyboard = [
- 'one_time' => false,
- 'buttons' => [
- [
- getBtn("1", 'negative', '1'),
- getBtn("2", 'negative', '2'),
- getBtn("3", 'negative', '3'),
- ],
- [
- getBtn("4", 'negative', '4'),
- getBtn("5", 'negative', '5'),
- getBtn("6", 'negative', '6'),
- ],
- ]
- ];
- $request_params = array
- (
- 'message' => "Привет",
- 'user_id' => $userId,
- 'access_token' => $token,
- 'keyboard' => json_encode($keyboard),
- 'v' => '5.50'
- );
- $get_params = http_build_query($request_params);
- file_get_contents('https://api.vk.com/method/messages.send?' . $get_params);
- }
- echo('ok');
- break;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement