Retrieve tweets using multiple twitter accounts for the search API

You can read my last article before you proceed with further, where you can read how to use Twitter4J API which enables us to fetch more then 100 tweets. The idea is simple. Twitter search API allows the use of multiple accounts. You may create multiple accounts for search API and switch the sessions when one account reach it’s threshold. Repeat the search process as long as you can. Once the first app reach to the limit, program will automatically switch the keys and retrieve session with new app. By this way you can download unlimited tweets. The only limitation is the rate limits which controls how fast you make the calls and subject to how much data Twitter can find for you in the search index.

To run the following program create a text file with the name “AllkeyFile” and add your keys of multiple apps.  The example is given below.

App1

consumer key

consumer secret

access token

access secret

App2

consumer key

consumer secret

access token

access secret

You may continue with several app details.

KeyHandler class is used to read keys from file and stored in a list in order. Once the session of 1st key is over, the application will connect through 2nd key.

Finally, a class to right tweets in a csv file.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.