admin管理员组文章数量:1420214
I am using the Twitter web-intents / javascript API, and I'm a bit surprised. What I'd like to do is listen for an event after a tweet occurs. Following their example:
twttr.events.bind('tweet', function(event) {
// Do something there
});
However, what I'd like to do is store the tweet id, or some other relevant information. If I take a look at the event
object, there doesn't appear to be any relevant information in the data
attribute.
Is it possible to obtain the tweet ID (or any other details about the tweet) by listening to a tweet event?
I am using the Twitter web-intents / javascript API, and I'm a bit surprised. What I'd like to do is listen for an event after a tweet occurs. Following their example:
twttr.events.bind('tweet', function(event) {
// Do something there
});
However, what I'd like to do is store the tweet id, or some other relevant information. If I take a look at the event
object, there doesn't appear to be any relevant information in the data
attribute.
Is it possible to obtain the tweet ID (or any other details about the tweet) by listening to a tweet event?
Share Improve this question edited Jun 4, 2021 at 14:22 Brian Tompsett - 汤莱恩 5,89372 gold badges61 silver badges133 bronze badges asked May 31, 2012 at 21:48 NT3RPNT3RP 15.4k9 gold badges63 silver badges97 bronze badges 6- 1 Have you had any luck with this? I only receive a null value for event.data – Owen McAlack Commented Sep 11, 2012 at 6:05
-
As stated in the ment to ascii-lime's answer, the
data
value is null. I have not had any luck with this :( – NT3RP Commented Sep 11, 2012 at 15:26 - Seems like the event.data.user_id is only populated on "follow" event, I couldn't find an answer for your question, did you? – Tangocoder Commented Jan 17, 2013 at 6:05
- I have the same problem, anyone know the answer? – Jacka Commented Nov 6, 2014 at 11:21
- Same problem here, data is always null :`( – Pioz Commented Apr 9, 2015 at 23:17
3 Answers
Reset to default 4 +50Web Intent events exist as a mechanism to trigger functionality in your page, not a data API.
The tweet event gets fired to indicate that a Tweet has happened, but we don't provide identifying information through the event payload: Intents function on your site without a user authorizing you access to their account, and providing a Tweet ID for an anonymous user's action would implicitly provide you with their identity.
If you want the tweet id you can use twitter's streaming API where they provide almost all the details with regards to a tweet.
But this has a catch as you will need to know the hashtag or at-least a part of the content of the tweet.
As Xeno as cited, you're not able to get such information from the Browser JS Widget from Twitter. The Event Bindings are only intended to the following purpose:
By adding listeners to the actions users perform in Web Intents, you can trigger functionality in your app, or send (anonymous) data about those events to your web analytics system (like Google Analytics, Omniture, or your own analytics engine.)
So basically, you're able to do something within your app after the user has tweeted something.
At this JSBin (http://jsbin./nalexuwuhi/1/) I've just created a basic test, where you're able to see the whole event object. The "tweet_id" value is only intended to "say" twitter to which tweet you're responding, e.g. the parent tweet and not what the tweet_id of the create tweet is. I think for such purpose you have to use the twitter api and therefore some server-side coding.
本文标签: javascriptHow to get Tweet ID from tweet eventStack Overflow
版权声明:本文标题:javascript - How to get Tweet ID from tweet event - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745324277a2653517.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论