我正在使用 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/