javascript - Twitter API Javascript 扩展模式

标签 javascript json node.js twitter

我正在使用 Twitter 流 API 和 Javascript 来收集推文。问题是我没有使用扩展模式,当推文超过 140 个字符时我无法获得完整的推文。我搜索了信息,发现我需要在请求中传递 tweet_mode=extended,响应将包含完整的推文 full_text。问题是我不知道在哪里写tweet_mode=extended。这是我的代码:

    twitter.stream('statuses/filter', {track: word, function (stream) {
            stream.on('data', function (tweet) {
                 console.log(tweet.text)
            });
            stream.on('error', function (error) {
                console.log("error:", error);
            })
        })

最佳答案

不幸的是,流媒体 API 没有添加 tweet_mode 参数的选项

此处的文档:https://developer.twitter.com/en/docs/tweets/tweet-updates

这一段值得注意您的担忧:

The Streaming API does not provide the same ability to provide query parameters to configure request options. Therefore, the Streaming API renders all Tweets in compatibility mode at this time.

...

Streaming API consumers should update their code to first check for the presence of the extended_tweet dictionary, and use that in preference to the truncated data as is applicable for their use case. When extended_tweet is not present, they must fall back to using the existing fields.

关于javascript - Twitter API Javascript 扩展模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50612543/

相关文章:

javascript - 获取 HTML 元素在主体坐标中的位置

java - JSNI:JavaScriptObject 和 Element JSNI 函数参数的区别?

json - 如何使用 Adob​​e Flex 发布 JSON

javascript - MongoDB $cmp(聚合)给出错误结果

javascript - 是否有相当于 ios 自动布局约束概念的 JavaScript 或 Web 开发库?

javascript - 访问 jQuery 插件中的原始目标元素

java - 使用 AsyncTask 获取 JSON 时,ProgressDialog 永远不会被关闭

java - 如何去除JSONArray String 中不需要的对象名?

node.js - 如何将 nodemon/grunt 与 .env 文件一起使用?

javascript - findLastIndex 不是一个函数,如何,为什么