This module provides a Twitter Status, Message, Friendship suppliers that can be reused and composed in various applications.
java.util.function.Supplier
The Twitter’s Standard search API (search/tweets) allows simple queries against the indices of recent or popular Tweets. This Source
provides continuous searches against a sampling of recent Tweets published in the past 7 days. Part of the 'public' set of APIs.
Returns a collection of relevant Tweets matching a specified query.
You can import the TwitterSearchSupplierConfiguration
in the application and then inject the following bean.
twitterSearchSupplier
You need to inject this as Supplier<Message<byte[]>>
.
You can use twitterSearchSupplier
as a qualifier when injecting.
Once injected, you can use the get
method of the Supplier
to invoke it.
The configuration properties prefixed with twitter.search
.
There are also properties that need to be used with the prefix twitter.connection
.
The spring.cloud.stream.poller
properties control the interval between consecutive search requests. Rate Limit - 180 requests per 30 min. window (e.g. ~6 r/m, ~ 1 req / 10 sec.)
For more information on the various options available, please see TwitterSearchSupplierProperties. See TwitterConnectionProperties and DefaultPollerProperties
See this README where this supplier is used to create a Spring Cloud Stream application where it makes a Twitter Search Source.
Provides real-time, Tweet streaming based on the Filter and Sample APIs.
The Filter API
flavor returns public statuses that match one or more filter predicates.
The Sample API
flavor returns a small random sample of all public statuses.
This supplier gives you a reactive stream of tweets from the configured connection as the supplier has a signature of Supplier<Flux<Message<?>>>
.
Users have to subscribe to this Flux
and receive the data.
The default access level allows up to 400 track keywords, 5,000 follow user Ids and 25 0.1-360 degree location boxes.
You can import the TwitterStreamSupplierConfiguration
in the application and then inject the following bean.
twitterStreamSupplier
You need to inject this as Supplier<Flux<Message<?>>>
.
You can use twitterStreamSupplier
as a qualifier when injecting.
Once injected, you can use the get
method of the Supplier
to invoke it and then subscribe to the returned Flux
.
All configuration properties are prefixed with twitter.stream
.
There are also properties that need to be used with the prefix twitter.connection
.
For more information on the various options available, please see TwitterStreamSupplierProperties. See TwitterConnectionProperties also.
See this README where this supplier is used to create a Spring Cloud Stream application where it makes a Twitter Stream Source.
Repeatedly retrieves the direct messages (both sent and received) within the last 30 days, sorted in reverse-chronological order.
The relieved messages are cached (in a MetadataStore
cache) to prevent duplications.
By default an in-memory SimpleMetadataStore
is used.
The twitter.message.source.count
controls the number or returned messages.
The spring.cloud.stream.poller
properties control the message poll interval.
Must be aligned with used APIs rate limit
You can import the TwitterMessageSupplierConfiguration
in the application and then inject the following bean.
twitterMessageSupplier
You need to inject this as Supplier<Message<byte[]>>
.
You can use twitterMessageSupplier
as a qualifier when injecting.
Once injected, you can use the get
method of the Supplier
to invoke it.
The configuration properties prefixed with twitter.search
.
There are also properties that need to be used with the prefix twitter.connection
.
The spring.cloud.stream.poller
properties control the interval between consecutive search requests. Rate Limit - 180 requests per 30 min. window (e.g. ~6 r/m, ~ 1 req / 10 sec.)
For more information on the various options available, please see TwitterMessageSupplierProperties. See TwitterConnectionProperties and DefaultPollerProperties
See this README where this supplier is used to create a Spring Cloud Stream application where it makes a Twitter Message Source.
Returns a cursored collection of user objects either for the users following the specified user (followers
) or for every user the specified user is following (friends
).
The twitter.friendships.source.type
property allow to select between both types.
Tip
|
Rate limit: 15 requests per 30 min window. ~ 1 req/ 2 min |
You can import the TwitterFriendshipsSupplierConfiguration
in the application and then inject one the following beans.
-
followersSupplier
(only iftwitter.friendships.source.type=followers
) - retrieves the users following the specified user (followers
) -
friendsSupplier
(only iftwitter.friendships.source.type=friends
) - retrieves the for every user the specified user is following (friends
).
Both suppliers expose Supplier<List<User>>
.
-
deduplicatedFriendsJsonSupplier
- retrieves either the followers, or the friends collection (controlled by thetwitter.friendships.source.type
) property, . encoded as JSONMessage
payloads. You need to inject this asSupplier<Message<byte[]>>
.
The configuration properties prefixed with twitter.friendships.source
.
There are also properties that need to be used with the prefix twitter.connection
.
The spring.cloud.stream.poller
properties control the interval between consecutive search requests.
For more information on the various options available, please see TwitterFriendshipsSupplierProperties. See TwitterConnectionProperties and DefaultPollerProperties