javascript – How to get hooked on like a photo on VKontakte and find out as soon as someone likes this photo?

Question:

How to get hooked on like a photo on VKontakte and find out as soon as someone likes this photo?
I created an application and there is a "Like" button (or another option – I'll just post a photo on VKontakte) and I need my server to immediately know that the photo has been liked.
You can get likes https://vk.com/dev/likes.getList , but I want them to update themselves like VKontakte.

<script type="text/javascript" src="openapi.js"></script>

<div id="vk_like"></div>


<script type="text/javascript">

      VK.init({apiId: 5309489});


    VK.Widgets.Like("vk_like", {type: "button"},55);
    VK.Observer.subscribe("widgets.like.liked", function f()
    {
        alert ("Thank you for your like.");
    });

</script>  //этот код не работает в режиме реального времени

How to do this?

Answer:

Understood. Just place this code directly there. where the person clicks. And I tried to place it on another page and get data there. when the user clicked.

VK.Observer.subscribe("widgets.like.liked", function f()
    {
        //Здесь отправляем данные на свой сервер
    });
Scroll to Top