Answer the question
In order to leave comments, you need to log in
How to check if a person is in a group?
Is it necessary to have an application to check if a person is a subscriber of the group where the bot works?
If not, how can this be implemented? (You will need to display a message if the person is not subscribed.
switch ($data->type){
case 'confirmation':
echo $confirmation_token;
break;
case 'message_new':
$user_id = $data->object->user_id;
$sostoit = file_get_contents('https://api.vk.com/method/groups.isMember?group_id='. $group_id .'&user_id='. $user_id .'extended=1');
$member = json_decode($sostoit, true);
if ($member['response']['member']==0){
$request_params = [
'message' => "Сначала в группу вступи!",
'user_id' => $user_id,
'access_token' => $token,
'v' => $api_version
];
$get_params = http_build_query($request_params);
file_get_contents('https://api.vk.com/method/'. $msg_send . $get_params);
echo('ok');
break;
}
else {
Тут остальной код, если человек состоит в группе
}
Error: HTTP response code said error. Attempt 1/5
Error: HTTP response code said error. Attempt 2/5
Answer the question
In order to leave comments, you need to log in
Issue resolved.
The group membership check request should look like this:
https://api.vk.com/method/groups.isMember?group_id= ".$group_id ."&user_id=".$user_id."&extended=1&access_token=".$token ."&v=".$api_version);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question