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.
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.
Anyone have a solution?
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
2
Answers
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.
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
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.
I couldn’t find a solution neither, so I coded it using pieces of code and ideas as the previous @JeffProd one, and avoiding using a lib. I hope it could help you.
PS: You must apply for a Twitter Developer Account and create an app to get your TOKENs and KEYs.