Hello,
I try to get some information about the twitter user when he clicks on tweet button (like user_id or screen_name). For test purpose I add a simple tweet button on an html page and some javascript code as I described below :
This is the code to get information on tweet event :
<script type="text/javascript">
twttr.ready(function (twttr) {
function handleTweetEvent(event){
if (event.data) {
alert(event.data.tweet_id+' '+event.data.source_tweet_id+' '+event.data.screen_name+' '+event.data.user_id);
}
}
twttr.events.bind('tweet', handleTweetEvent);
});
</script>
But my javascript alert renders : “undefined undefined undefined undefined”.
My tweet button looks like this :
<a href="https://twitter.com/share" class="twitter-share-button">Tweet</a>
And according to this part of the documentation : https://dev.twitter.com/docs/intents/events, I added this snippet in the head section of my html page :
<script type="text/javascript" charset="utf-8">
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="//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"));
</script>
I don’t understand why all attributes are “undefined” ? Do you have an idea about this problem?
Thanks a lot for your help.