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

  • Twitter Streaming API


    I gather things are still in the early stages, but are there any code examples or documentation for the Twitter streaming API?

    In our web application we want a website user to be able to define a twitter hashtag search term and have the results streamed back in realtime. Given the restrictions of the API, is this something that is possible using Spring Social Twitter?

  • #2
    There's not a sample showing this yet, but it's on my TODO list to create one or amend Spring Social Showcase to demonstrate this. Keep an eye on the spring-social-samples for this to appear soon.


    • #3
      Craig, thanks for your quick response and work on Spring Social. I'll keep an eye out on the samples.

      I have a couple of questions regarding the streaming limits. Proper use of the Streaming API states that where possible only one connection should be used, and that for default access there is a 400 keyword filter limit.

      In the Spring Social Twitter Streaming API implementation, is there any way to monitor the number of tracked keywords being filtered? Can I remove filtered keywords from the stream? Finally what happens when the limit is reached?


      • #4
        Looking at the Twitter4j library it's possible to maintain a list of keywords to filter:

        FilterQuery fq = new FilterQuery();
        String keywords[] = {"#disney", "#MickeyMouse"};
        Is anything similar possible with Spring Social?


        • #5
          Is "Stream filter(String trackKeywords, List<StreamListener> listeners);" not what you want? You can give it keywords to filter on (as a comma-separated list in a String...wondering if I should overload that to take a String array).


          • #6
            Great! I didn't know you could give it comma-separated values, thanks.

            I found though that if you filter again, it does not overwrite the previous filter, so there is no way remove previous search strings?

            For example, with the following code it still streams #disney after the second line of code. Is this intended behaviour? I ask because Twitter4J overwrites previous filters.

            Stream userStream = twitter.streamingOperations().filter("#disney", listeners);
            twitter.streamingOperations().filter("#MickeyMouse,#DaffyDuck", listeners);