E
E
Eugene2016-03-19 16:58:37
JavaScript
Eugene, 2016-03-19 16:58:37

How to check that the user is in the VK group after clicking on Like?

There is a condition for receiving a discount: "must be in a group and like or share with friends"
How to add a check for other conditions to the "Like" widget?
For example, so that after a like on the VK.Observer website, check if the user is in the group?

<script type="text/javascript" src="//vk.com/js/api/openapi.js?84"></script>

<script type="text/javascript">
  VK.init({apiId: XXXXXX});
</script>
<div id="vk_like"></div>
<script type="text/javascript">
VK.Widgets.Like("vk_like", {type: "button"});
VK.Observer.subscribe("widgets.like.liked", function f()
{
alert ("Thank you for your like.");
});
</script>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Petr Flaks, 2016-03-19
@neluzhin

I guess the best scheme would be something like this:

  1. Ask the user to like;
  2. Place an authorization button via VK somewhere near the like widget, get the user ID and use the groups.isMember method to find out if the user is in a group.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question