分开Twitter的流式响应以进行跟踪/跟踪

时间:2019-09-03 14:36:25

标签: twitter twitter4j twitter-streaming-api

我创建了一个流查询,其中包含400个跟踪关键字和5,000个跟踪关键字。

当我从Twitter收到响应时,如何关联触发该响应的关注/关键字?

1 个答案:

答案 0 :(得分:0)

其中一位Twitter开发人员回答:

Twitter dev froum link

匹配如下: 简而言之,Twitter文档说:

1.Tweets created by the user.
2.Tweets which are retweeted by the user.
3.Replies to any Tweet created by the user.
4.Retweets of any Tweet created by the user.
5.Manual replies, created without pressing a reply button (e.g. “@twitterapi I agree”).

匹配发布用户ID:

1 and 2 are in the user object of the top-level tweet, like tweet['user']['id']

4 is the inner-level tweet, retweeted_status - so tweet['retweeted_status']['user']['id'] should be one of your follow ids.

3 can be checked in in_reply_to_user_id field, or mentions.

5 and 3 can be checked together from the mentions: tweet['entities']['user_mentions']

Additionally, if "truncated": true you might have to dig into extended_tweet

要匹配曲目,我只构建一个正则表达式并尝试与关键字匹配。我还喜欢使用内存中的Lucene解析器。

相关问题