Twitter and facebook share with callbacks?

后端 未结 4 1824
無奈伤痛
無奈伤痛 2020-12-23 15:19

I have implemented facebook and twitter share to my website. The users are redirected to the following URLs when they click on the twitter or facebook share button.

4条回答
  •  天命终不由人
    2020-12-23 15:51

    For Twitter call with callback, that is how I did it in Javascript:

    // Include the Twitter Library
    window.twttr = (function (d,s,id) {
      var t, js, fjs = d.getElementsByTagName(s)[0];
      if (d.getElementById(id)) return; js=d.createElement(s); js.id=id;
      js.src="https://platform.twitter.com/widgets.js"; fjs.parentNode.insertBefore(js, fjs);
      return window.twttr || (t = { _e: [], ready: function(f){ t._e.push(f) } });
    }(document, "script", "twitter-wjs"));
    
    // On ready, register the callback...
    twttr.ready(function (twttr) {
        twttr.events.bind('tweet', function (event) {
            // your callback action here...
        });
    });
    

    The twitter link is like this:

          Share on Twitter
    

    Reference: https://dev.twitter.com/docs/intents/events

提交回复
热议问题