<?php
if (!isset($_REQUEST)) {
return;
}
$confirmationToken = ;
$token = '';
$secretKey = '';
$data = json_decode(file_get_contents('php://input'));
//$app->post('/', function() use($app)) {
//}
if(strcmp($data->secret, $secretKey) !== 0 && strcmp($data->type, 'confirmation') !== 0)
return;
switch ($data->type) {
case 'confirmation':
echo $confirmationToken;
break;
case 'message_new':
$from_id = $data->object->from_id;
$peer_id = $data->object->peer_id;
$message = $data->object->text;
$userInfo = json_decode(file_get_contents("https://api.vk.com/method/users.get?user_ids=".$from_id."&v=5.8&access_token=".$token));
$user_name = $userInfo->response[0]->first_name;
$request_params = array(
'message' => "Привет",
'user_id' => $from_id,
'access_token' => $token,
'v' => '5.80'
);
$get_params = http_build_query($request_params);
file_get_contents('https://api.vk.com/method/messages.send?' . $get_params);
echo("Hello");
break;
}
?>