Announcement Announcement Module
No announcement yet.
Support for Twitter Streaming API Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Support for Twitter Streaming API


    Do you have support for Twitter streaming API and perhaps a working example?


  • #2
    There's a good start on the Twitter streaming API work in the latest snapshot builds. I do not currently have an example of its use outside of tests, but I should bake one up. I'll try to get an example out there soon. In the meanwhile, here's some code that I've been using to observationally test it:

    		TwitterTemplate twitter = new TwitterTemplate("YR571S2JiVBOFyJS5MEg", "Kb8hS0luftwCJX3qVoyiLUMfZDtK1EozFoUkjNLUMx4", "7078572-srXzIDwmIc0lg69TBR0rLr9TqHYJiRqPIv14gunpk", "xfnQDjYEcdTCcYWeLcJyGuszQG9R5UnG5TrvtfG33BU");
    		List<StreamListener> listeners = new ArrayList<StreamListener>();
    		StreamListener listener = new StreamListener() {			
    			public void onTweet(Tweet tweet) {
    				System.out.println("TWEET:  " + tweet.getFromUser() + "   -   " + tweet.getText());
    			public void onLimit(int numberOfLimitedTweets) {
    				System.out.println("LIMIT:  " + numberOfLimitedTweets);
    			public void onDelete(StreamDeleteEvent deleteEvent) {
    				System.out.println("DELETE:  " + deleteEvent.getTweetId());
    			public void onWarning(StreamWarningEvent warnEvent) {
    				System.out.println("WARNING:  " + warnEvent.getCode());
    		UserStreamParameters params = new UserStreamParameters().with(WithOptions.FOLLOWINGS).includeReplies(true);
    //		Stream userStream = twitter.streamingOperations().sample(listeners);
    		Stream userStream = twitter.streamingOperations().filter("Disney", listeners);
    //		twitter.streamingOperations().sample(listeners);
    It's non-ideal as an example, but it should give you an idea of how to use the API binding.

    I've had the streaming code in GitHub and snapshot builds for over a month while I fine-tune it. So far, nobody has given me any feedback on it. If you try it out, *PLEASE* let me know what you think. It's always better to get feedback from the community while it's still in snapshot or milestone releases than to get it later when it's in a GA release.


    • #3
      Craig - can you provide me the exact snapshot version for maven dependency and the maven repository where it can be located?


      • #4
        As with most Spring projects, snapshots can be found at Specifically, the pom.xml entries should be:

        ...and then in your repositories entries:

          <name>Spring Maven Snapshot Repository</name>
        Although the Spring Social Showcase doesn't use Twitter streaming, you can look at its pom.xml file to see what's needed.

        If you're using Gradle, then it's slightly easier:

        compile ("")
        ...and in your repositories declaration:

        repositories {
          maven { url '' }


        • #5
          Correct me if I'm wrong and I very well may be, but I don't believe the Streaming API binding is in any of the versions of Spring Social Twitter, including the latest snapshot build (1.1.0.BUILD-20130530.081517-388).

          Assuming I was doing something wrong, I went ahead and manually checked the source as well as the docs in hopes of finding it.


          If I'm missing something, I apologize and thanks in advance for pointing me in the right direction. If not, I'd appreciate it if you could include it in the next snapshot as it is pivotal to my next leg of development, and I'd rather not implement twitter4j only to remove it when Spring has a better binding.


          • #6
   mistake. I had assumed that I had pushed it to GitHub, but I hadn't. I've been working on it in a separate branch on my local machine and never merged it and pushed it to GitHub. I'll see about doing that sometime today and let you know.


            • #7
              I just merged the streaming stuff into the master branch and the snapshot is building as I write this.

              I had some unfinished work on upgrading to Jackson 2 that I had to complete before I could merge in the streaming stuff, or else I'd have finished it earlier today.