I
I
Ivan Nesterovich2013-12-15 21:09:41
Facebook
Ivan Nesterovich, 2013-12-15 21:09:41

Callback if user shared page (vk, fb, od, tw)?

There is a desire to encourage the user with all sorts of goodies if he shared the page in one of the social networks: Vkontakte, Facebook, Odnoklassniki, Twitter.
It is desirable to use window.open, if not, then through the API.
Maybe there are third-party services that help to implement this?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
H
hommedeplage, 2014-04-17
@hommedeplage

Good afternoon! I have the same question. I would like to figure out how to make a callback when sharing in VK. Facebook is very easy. In their documentation, in the example, a callback is made when sharing.
Have you figured out VK? Tell me, please, how to do it.
Below is an example of a callback in FB

<div id="fb-root"></div>
    <script>
      window.fbAsyncInit = function() {
        FB.init({
          appId      : 445457008923933,
          status     : true,
          xfbml      : false
        });
      };
      function popup(){ 	
    	FB.ui(
      {
        method: 'feed',
        name: 'name - Тестим',
        caption: 'Какой-то caption',
        description: 'ДАДАДАДАДАДААДАДДА',
        link: 'https://developers.facebook.com/docs/reference/javascript/'
      },
      function(response) {
            if (response && response.post_id) {
              alert('Молодец!');
            } else {
              alert('плохо =(');
            }
        	}
    );

      }

      </script>

<style type="text/css">
  body,html {
    position: relative;
    height: 100%;
    width: 100%;
  }
  .fb-like {
    position: absolute;
    margin: auto;
    left: 0;
    top: 0;
    bottom: 0;
    right: 0;
    height: 400px;
    width: 400px;
    background: red;
    color: white;
    font-size: 30px;
    cursor: pointer;
  }
</style>
<script>
(function(d, s, id){
               var js, fjs = d.getElementsByTagName(s)[0];
               if (d.getElementById(id)) {return;}
               js = d.createElement(s); js.id = id;
               js.src = "//connect.facebook.net/ru_RU/all/debug.js";
               // uncomment on production
               // js.src = "//connect.facebook.net/ru_RU/all.js";
               fjs.parentNode.insertBefore(js, fjs);
             }(document, 'script', 'facebook-jssdk'));
</script>
    <div class="fb-like" onclick="popup()"> Нажми и расшарь!</div>

A
Alexey Krichko, 2014-06-02
@sand_alkr

With vk everything is even easier than with fb:

<head>
...
<script type="text/javascript" src="//vk.com/js/api/openapi.js?113"></script>
<script type="text/javascript">
  VK.init({apiId: ваш_appId, onlyWidgets: true});
</script>
</head>
<body>
...
<div id="vk_like"></div>
<script type="text/javascript">
  VK.Widgets.Like("vk_like", {type: "button"});
  VK.Observer.subscribe("widgets.like.shared", function f() {
    alert('Молодец!');
  });
</script>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question