1

I am making a Spring Social Twitter application using Spring Boot. I have already configured a Twitter object using the consumerId, consumerKey, accessToken, and accessTokenSecret.

My question is how can I use Spring Social Twitter to monitor the configured Twitter account and invoke a method whenever any user mentions my Twitter account. The method should be invoked with the Tweet object or the tweet ID.

For example, let's indicate that my account is @MyAccount. Now let's imagine that @SomeOtherAccount tweets at (or mentions) @MyAccount. Since another user tweeted at my account, a method should be invoked with the respective tweet data from @SomeOtherAccount.

codingbash
  • 1,102
  • 1
  • 9
  • 21

1 Answers1

0

Spring Social Twitter's primary purpose is not what you are trying to achieve. Spring Social and its extensions were intended to provide Easy Authentication, Accessing Profile Data, Easy Posting of Status/Messages, Logout etc.

The best framework for the Use case you have is Spring XD. If you follow these Spring XD and pivotal tutorials which shows how to search for a Term (java in this case) on Twitter and save those tweets into a File.

You just need to modify the same to search for your @MyAccount and take actions for the Tweets with that name mentioned.

You can read the following post written by me on how to analyse tweets with a custom processor

shazin
  • 21,379
  • 3
  • 54
  • 71
  • I thought that Spring Social Twitter is essentially an abstraction and binding of Twitter REST API? I assume Twitter REST API provides some sort of way to achieve my desired outcome. I will try and see if there is a way to achieve this with Spring Social solely, although after, I can then try your suggestion as an opportunity to learn Spring XD. – codingbash Dec 27 '16 at 15:52
  • 1
    So Spring Social Twitter does provide a method to get the user's mentions. Obviously Twitter REST API does not provide a webhook for new mentions. Although, what I did was create a Spring `@Scheduler` to check for new mentions by utilizing the `sinceId` parameter. http://docs.spring.io/spring-social-twitter/docs/1.0.5.RELEASE/api/org/springframework/social/twitter/api/TimelineOperations.html#getMentions() – codingbash Dec 28 '16 at 16:53