Roland Dunn
Roland Dunn

Reputation: 111

Web Intent Callback Events via Window.open Just Not Happening

Wonder if anyone can help. See attached code below:

I would like to use the window.open approach, and get the callback. Any thoughts anyone?

<!doctype html>
<html lang="en">
<head lang=en>
    <meta charset="utf-8">
    <title>Web Intent t3 Experiment</title>
    <script src="http://d3js.org/d3.v3.min.js"></script>
    <script src="https://platform.twitter.com/widgets.js" type="text/javascript">    </script>
</head>
<body>

<a href="https://twitter.com/intent/tweet?url=http://www.google.com&text=testing web intents">Option 1: Tweet via Link</a><br />
<button id="tf_sendtweet_button">Option 2: Tweet Via Button and JS</button>

<script type="text/javascript">
var t_element = d3.select("#tf_sendtweet_button");
t_element.on("click", function() {
        _text = "Some compelling text to go in a tweet";
        _url = "http://www.google.com/";

        var tweet_url = 'https://twitter.com/intent/tweet?text=';
        tweet_url += encodeURIComponent(_text);
        tweet_url += '&url=' + encodeURIComponent(_url);
        window.open(tweet_url,'_blank');
});



// Here, trap the callback from the WebIntent.
twttr.ready(function (twttr) {
    // bind events here
    twttr.events.bind('tweet', function (event) {
        alert("Yay, tweet callback baby. Gotcha.");
        console.log(new Date(), "Sweett, tweet callback: ", event);
    });
}); 
</script>
</body>
</html>

Upvotes: 3

Views: 2989

Answers (1)

Roland Dunn
Roland Dunn

Reputation: 111

Ok, everyone stand easy. It's been answered by a Twitter employee:

Unfortunately you can’t use the callback events features without letting our javascript control the window opening.

https://twittercommunity.com/t/get-web-intent-callback-from-a-window-open-call/20881

Upvotes: 1

Related Questions