node.js - 使用流 API 跟踪推特主题标签(关键字)

标签 node.js tweetstream

我正在尝试通过给定的主题标签或关键字来跟踪所有推文。问题是,当我使用像“动物”这样的简单关键字时,我可以流式传输推文,但当我将其更改为“animal4666”时,它就不起作用了。没有收到回复。我正在使用下面的代码。

    twit.stream('statuses/filter', { track: 'animal4666' }, function(stream) {
        stream.on('data', function(data) {
            console.log(util.inspect(data));
        });
    });

我从不同的帐户发了两条推文,如下所示:

'#animal4666a'

“#animal4666 试图找出发生了什么?”

以上推文已使用搜索 API 成功检索,但由于搜索 API 的速率限制,我需要使用流 API,以便我可以使用 node.js 每两秒检查一次新推文

我正在使用的 node.js 插件:https://github.com/jdub/node-twitter

有人可以帮忙吗?

最佳答案

如果您查看 code你正在使用的库,似乎没有什么潜在的错误
当您在跟踪参数中传递数组时,它只有一个解决方法,但事实并非如此

// Workaround for node-oauth vs. twitter commas-in-params bug
if ( params && params.track && Array.isArray(params.track) ) {
    params.track = params.track.join(',')
 }

因此查看 official api docs对于跟踪方法,我看到两个可能相关的注意事项。

Each phrase must be between 1 and 60 bytes, inclusive.

我认为你的更短,但要记住这一点

我认为你真正的问题是:

Exact matching of phrases (equivalent to quoted phrases in most search engines) is not supported.

Punctuation and special characters will be considered part of the term they are adjacent to. In this sense, "hello." is a different track term than "hello". However, matches will ignore punctuation present in the Tweet. So "hello" will match both "hello world" and "my brother says hello." Note that punctuation is not considered to be part of a #hashtag or @mention, so a track term containing punctuation will not match either #hashtags or @mentions.

您可以在线检查您的推文文本,看它是否匹配 here

关于node.js - 使用流 API 跟踪推特主题标签(关键字),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19594265/

相关文章:

node.js - 带有 node.js 的 FFmpeg。将文件转码为另一种格式

java - 你如何保护 flutter 中的 restful api 端点

node.js - 使用 Typescript 向 expressjs 中的 req 对象添加属性

php - Twitter api php foreach 循环不适用于用户推文

ruby-on-rails - Heroku 上的 Rails 如何监控工作进程

python - 使用 Streaming API 避免 420?

python - 仅限制带地理标记的推文流向 mongodb

python - 如何使用 tweepy 获取标签中的所有推文?

node.js - Contextify@0.1.3 安装 : `node-gyp rebuild` failed with 1

javascript - socket io, node js, 将图像/文件从服务器发送到客户端的简单示例