vk.api does not perform the reversing test



  • Section <head> I'm connecting vk api.

    <script src='//vk.com/js/api/openapi.js' type='text/javascript'></script>
    

    Then I created a vk_share function to process the repost verification.

    function vk_share()
    {
        VK.init({
            apiId: my_id
        });
        console.log(VK.Api);
        VK.Observer.subscribe("widgets.like.shared", function f(){
            alert("Thank you for your shared.");
        });
    }
    

    And on the click, I'm challenging the function:

    <a onclick="vk_share()" target="_blank" href="http://vk.com/share.php?image=http://mysite.ru/pic4vk.jpg&description=Описание &url=http://mysite.ru&title=Заголовок"><img src="img/socials/vk.jpg" alt=""/></a>
    

    The repost is generated normally, but the alerth does not occur after the user has performed the repost. Tell me how to check the back of the water. UPD1 On Alexander's advice, he tried to add a view.

    VK.Widgets.Like("vk_like", {type: "button"});
    

    I get the following mistake:

    VK.Widgets: object #vk_like not found.
    

    Also added onlyWidget true. The repost verification code is like this.

        function vk_share()
        {
            VK.init({
                apiId: 5216642,
                onlyWidgets: true
            });
            VK.Widgets.Like("vk_like", {type: "button"});
            console.log(VK.Api);
            VK.Observer.subscribe("widgets.like.shared", function f(){
                alert("Thank you for your shared.");
            });
        }
    


  • Option - propose https://vk.com/dev/wall.post through the API, and receive the id of the created post in response. https://deserter.io/vktest.html ♪

    Connect. https://vk.com/dev/openapi ♪ do a button and some kind of crypt ♪

    VK.init({ apiId: XXXXXX }); // id вашего приложения ВК, где в настройках прописан ваш домен
    document.getElementById('btn-podel').addEventListener('click', hClick); // ждём нажатий на кнопку
    

    function hClick() { // обработчик нажатия
    VK.Api.call('wall.post', {message:"test"}, hPost);
    }

    function hPost(r) { // обработчик окончания выполнения API запроса
    if(!r) throw "Bad response from VK";
    if( r.error) { // если отказался постить
    console.log("Not posted. Error:", r.error);
    } else if( r.response) {
    if( r.response.post_id) { // это id свежесозданного поста
    console.log("Posted with id ", r.response.post_id);
    } else {
    console.log("No post id, no idea why", r);
    }
    } else {
    console.log("Not posted, no idea why", r);
    }
    }

    Insufficient This way is that the post is only on the user &apos; s wall. There's no choice but to see where to put on the wall, the community, the personal message.

    Benefits - that you get a id post, and by keeping it at your place, you can check in some time whether it's still hanging, and whether it's content. I used to run a mechanic where a laser made a raft, which should last at least 24 hours, only after that, a laser could get a &quot; reward &quot; - to download some file.




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2