I want to get the user_id of the user who tweets using javascript API


#1

Hi there,
I want to get the user_id of the user who tweets.

It works great when for follow button :

 <a href="https://twitter.com/gafitescu" class="twitter-follow-button">Follow @gafitescu</a>    
<script src="//platform.twitter.com/widgets.js" type="text/javascript"></script>
<script type="text/javascript">
    twttr.events.bind('follow', function(event) {       
        var followed_user_id = event.data.user_id;
        console.info( followed_user_id);
    });    
</script>

But when I try :

 <a href="https://twitter.com/share" class="twitter-share-button" data-url=" " data-count="horizontal" data-text="This is the tweet">Tweet</a>
<script src="//platform.twitter.com/widgets.js" type="text/javascript"></script>
<script type="text/javascript">
    twttr.events.bind('tweet', function(event) {
            console.warn(event);
            console.info(event.data) // this is empty
    });    
    
</script>

Thank you!


#2

This information is unavailable for the tweeting user – it would give you too much direct identifying information about the user currently on your site.


#3

So there is no other way than create an application that I can get that or there is any other way?


#4

If you create a server-to-server based OAuth implementation in which the user gives your application permission to act on their behalf, you would also create the tweeting experience and have knowledge of the user. Without that kind of “contract” between you and the user, you can’t know their account while they’re simply visiting and utilizing the Tweet Button from your page.

You can monitor recently created tweets pointing to your site using the Streaming API and Search API.


#5

"You can monitor recently created tweets pointing to your site using the Streaming API and Search API. "

By “pointing” you mean having a hash tag or a url and search for that pattern. This would work in the cases when user have their account private so their tweets won’t appear in the search.

I made it work using a twitter app and oauth.

thank you!


#6

Just my 2 pennies.
Since it’s possible to get statistics from search and/or streaming API about public tweets with a great hassle (and giving load to Twitter servers) I think it would be wise to introduce possibility that users with public timeline (which means that from around the corner from search API I can associate user_id and tweeted URL) would expose user_id and screen_name in data section when they tweet?

I think that would save huge amounts of time for devs like me and some fraction of infrastructure for Twitter :slight_smile:

Best regards,


#7

Hi May i know how can i get tweeted response using API


#8

please you assure me that there are no links in the paste. I like for my follow button on the site.


#9

reea_dev@
me too.
This is something I need to learn.
Can you say more clearly how to solve your are not?
I want to get the user_id of the user who tweets using javascript API.
Thanks


#10

#11