Twitter API-计算特定字符串的推文数量 [英] Twitter API - Count number of tweets of a specific string

查看:69
本文介绍了Twitter API-计算特定字符串的推文数量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用twitter api尝试获取一个整数,该整数告诉我给定的某个字符串有多少条tweet.

I'm using the twitter api to try to get an integer that tells me how many tweets there are to a certain string I give.

例如我搜索"mercedes",然后希望从Twitter获得一个整数:"1249".1249表示最近2周内有太多推文.据我所知,Twitter仅返回最近两周的数据.由于我的缘故,如果我取回所有记录并通过php或类似方法将其拉出也可以.我已经发送了一些测试请求,但始终只能返回最多20个条目的数组.

e.g. I search for "mercedes" and then want to get an integer back from twitter that says: "1249". 1249 would mean that there were so many tweets in the last 2 weeks. Twitter only returns data from the last 2 weeks as far as I know. Because of me it's also okay if I get all records back and pull them by means of php or the like. I have already sent some test requests, but always only get arrays back with a maximum of 20 entries.

有人有解决办法吗?

我已经看过类似的问题,但是找不到帮助我的东西.随着Twitter及其api的变化和发展,我看到的问题中的许多答案不再起作用

And I already looked at similar questions but couldn't find something that helped me. Many answers in the questions I have seen no longer work, as twitter and its api has changed and evolved

推荐答案

使用公共搜索API,您将仅获得最近7天的推文,而并非全部.因此您的结果将不准确.

Using the public search API, you will get tweets from the last 7 days only and not all tweets. So your results won't be accurate.

如果仍然要测试,则必须使用标准搜索API: https://developer.twitter.com/en/docs/tweets/search/api-reference/get-search-tweets.html

If you still want to test, you have to use the standard search API : https://developer.twitter.com/en/docs/tweets/search/api-reference/get-search-tweets.html

将"cout"参数设置为100,并检查结果中的"next_results"值以循环100条其他推文,依此类推,直到没有结果.

Set the "cout" parameter to 100, and check the "next_results" value in the results to loop 100 others tweets and so on until you get no result.

这篇关于Twitter API-计算特定字符串的推文数量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆