Get 'tweet' event from Twitter Web Intents


#1

I have such simple code for my site, but ‘tween’ event doesn’t trigger. Can someone help me?
NOTE: i need to use exactly window.open() to show tweet popup, because some other stuff should be done before twitter popup appears.

twttr.events.bind('tweet', function(event) { alert('tweet!!!'); });

function jsTweet() {
// some other stuff here
// …
var urlTW = “https://twitter.com/intent/tweet?text=Text&url=http://my_url.com”;
window.open(urlTW, “”, “toolbar=0, status=0, width=650, height=360”);
}


#2

Are you additionally loading widgets.js from platform.twitter.com?

While it’s likely unrelated, the format of URL in your urlTW variable is wrong – the URL parameter should be percent-encoded. Also, though I know it’s just a placeholder, underscores in a domain name are invalid and this will not likely be evaluated as a valid URL.

Example with proper encoding and usage of a hyphen instead of an underscore:

var urlTW = “https://twitter.com/intent/tweet?text=Text&url=http%3A%2F%2Fmy-url.com”;

All that said, I’m having difficulty getting the tweet event to trigger in other tests I’m performing right now and I will continue looking into this possible bug. Thanks!


#3

URL doesn’t matter, because my code above is just for an example. And of course it is supposed that widgets.js was loaded. Anyway, I am Looking forward to your answer.


#4

@episod, any news on this issue?


#5

When it came time to look into this in more detail we were unable to reproduce the issue. However, I’ll take another look at this as soon as I get a chance.


#6

Web Intents Events does not work. I have tried every which way to bind to the tweet event, but it is never fired. This is a bug guys. Please let us know a realistic timescale for fixing it. This is a pretty essential solution for me and a lot of other developers because your API tools suite doesn’t include a Javascript SDK - there is no other way of easily using Twitter from Javascript! Surely you must have run successful tests for the Web Intents service during development. How did you make it work then?


#7

I’ve begun engaging with you on Twitter about this after your @mention last night. When you have a chance to look into my suggestions, we can resume the conversation here.


#8

this issue is 100% reproducible. Just try to run example from my first post.


#9

Have you tried binding these events while using the pop-up code already provided by widgets.js? If you want to track the events, you should be relying on the widgets.js code to handle the window invocation.


#10

i’m having the same problem, the bind events don’t seem to do anything when using the standard twitter button (that render in an iframe). if i put a plain link on my page then the bind events work…but i want the standard button to work so i get the default look/feel as well as the number of tweets. any chance there’s a solution for that?

Tweet

Retweet


#11

apparently there is a blocking bug with the IE implementation of the button


#12

Web Intents Event for “tweet” is not working at all for any browser if I am using window.open.


#13

window.open more often than not gets blocked by browser popup blockers. You need to call that function in response to a user action, for example, in a click event handler.


#14

I am doing the same thing.
For example,

My onclick function
function twitterShareClick() {
twttr.events.bind(‘tweet’, function (event) {
alert(‘testing’);
});

window.open(“https://twitter.com/intent/tweet?url=” + myURL+ “&text=myText”, “Twitter”, “status = 1, left = 430, top = 270, height = 550, width = 420, resizable = 0”);
}

I don’t see any problem with this code


#15

Make sure your event listener is firing - you should also make sure that you’re serving your page from http:// or https://, not file:/// URLs.

The following code worked fine for me:

This is text Link

#16
This is text Link

#17

twttr.events.bind(‘tweet’, function(event) {
alert(‘tweet!!!’);
});

function jsTweet() {
// some other stuff here
// …
var urlTW = “https://twitter.com/intent/tweet?text=Text&url=http://my_url.com”;
window.open(urlTW, “”, “toolbar=0, status=0, width=650, height=360”);
}


#18

You can check my link here.

http://www.dhavalpatels.com/twitter/twittertest.html
Its the same code.


#19

Neither Chrome, Firefox, nor Safari had a problem opening the popup from that URL. Which browsers/operating systems do you have an issue with?


#20

The pop up is opening perfectly but I am talking about the callback event i.e. twttr.events.bind. Its not getting fire.