We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello gracious Processing community,
I'm searching for good web references / walk-throughs of working with twitter stats. My intentions are to pull total quantities of reoccurring hashtags within the most recent 60 seconds. I want to provide realtime conversation stats. I am assuming that they're streaming API is going to be the way to go (versus the search api?), but I am not sure about this. I have setup an app, and I have all the necessary app credentials. I am just not sure about the technique in pulling all data needed and interpreting it.
I've checked out Jer Thorp's gracious tutorial here: http://blog.blprnt.com/blog/blprnt/updated-quick-tutorial-processing-twitter
But I'm not [yet] a strong enough coder to connect the dots from his process to where I want to go.
Any ideas / references would be greatly appreciated.
Thanks for the read!
-Jon
Answers
Hi Jon, I have just been doing some work myself with twitter4j. The code below is the basis of my sketches which stream tweets.
Things to note in the code:
keywords[] is where you can put in your hashtag search. This link has a good list of operators for the query https://dev.twitter.com/docs/using-search
You then create a filterQuery() with this keyword.
connectTwitter() and loadAccessToken() are just the setup methods to sort of your credentials.
The statusListener() is the magic object which continually monitors the stream. And the onStatus() method is called whenever a tweet matching your query comes in.
In the example I just print the tweet to my monitor. But you could load all of them into a String[] or even create a custom Tweet Class. Also look at this page https://dev.twitter.com/docs/platform-objects/tweets to see what is contained in the tweet object.
Hope this helps.