Spring Social Twitter

org.springframework.social.twitter.api
Interface TimelineOperations


public interface TimelineOperations

Interface defining the operations for sending and retrieving tweets.

Author:
Craig Walls

Method Summary
 void addToFavorites(long id)
          Adds a tweet to the user's collection of favorite tweets.
 void deleteStatus(long tweetId)
          Removes a status entry.
 java.util.List<Tweet> getFavorites()
          Retrieves the 20 most recent tweets favorited by the authenticated user.
 java.util.List<Tweet> getFavorites(int pageSize)
          Retrieves tweets favorited by the authenticated user.
 java.util.List<Tweet> getFavorites(long userId)
          Retrieves the 20 most recent tweets favorited by the specified user.
 java.util.List<Tweet> getFavorites(long userId, int pageSize)
          Retrieves tweets favorited by the specified user.
 java.util.List<Tweet> getFavorites(java.lang.String screenName)
          Retrieves the 20 most recent tweets favorited by the specified user.
 java.util.List<Tweet> getFavorites(java.lang.String screenName, int pageSize)
          Retrieves tweets favorited by the specified user.
 java.util.List<Tweet> getHomeTimeline()
          Retrieves the 20 most recently posted tweets, including retweets, from the authenticating user's home timeline.
 java.util.List<Tweet> getHomeTimeline(int pageSize)
          Retrieves tweets, including retweets, from the authenticating user's home timeline.
 java.util.List<Tweet> getHomeTimeline(int pageSize, long sinceId, long maxId)
          Retrieves tweets, including retweets, from the authenticating user's home timeline.
 java.util.List<Tweet> getMentions()
          Retrieve the 20 most recent tweets that mention the authenticated user.
 java.util.List<Tweet> getMentions(int pageSize)
          Retrieve tweets that mention the authenticated user.
 java.util.List<Tweet> getMentions(int pageSize, long sinceId, long maxId)
          Retrieve tweets that mention the authenticated user.
 java.util.List<Tweet> getRetweets(long tweetId)
          Retrieves up to 100 retweets of a specific tweet.
 java.util.List<Tweet> getRetweets(long tweetId, int count)
          Retrieves retweets of a specific tweet.
 java.util.List<Tweet> getRetweetsOfMe()
          Retrieve the 20 most recent tweets of the authenticated user that have been retweeted by others.
 java.util.List<Tweet> getRetweetsOfMe(int page, int pageSize)
          Retrieve tweets of the authenticated user that have been retweeted by others.
 java.util.List<Tweet> getRetweetsOfMe(int page, int pageSize, long sinceId, long maxId)
          Retrieve tweets of the authenticated user that have been retweeted by others.
 Tweet getStatus(long tweetId)
          Returns a single tweet.
 java.util.List<Tweet> getUserTimeline()
          Retrieves the 20 most recent tweets posted by the authenticating user.
 java.util.List<Tweet> getUserTimeline(int pageSize)
          Retrieves tweets posted by the authenticating user.
 java.util.List<Tweet> getUserTimeline(int pageSize, long sinceId, long maxId)
          Retrieves tweets posted by the authenticating user.
 java.util.List<Tweet> getUserTimeline(long userId)
          Retrieves the 20 most recent tweets posted by the given user.
 java.util.List<Tweet> getUserTimeline(long userId, int pageSize)
          Retrieves tweets posted by the given user.
 java.util.List<Tweet> getUserTimeline(long userId, int pageSize, long sinceId, long maxId)
          Retrieves tweets posted by the given user.
 java.util.List<Tweet> getUserTimeline(java.lang.String screenName)
          Retrieves the 20 most recent tweets posted by the given user.
 java.util.List<Tweet> getUserTimeline(java.lang.String screenName, int pageSize)
          Retrieves tweets posted by the given user.
 java.util.List<Tweet> getUserTimeline(java.lang.String screenName, int pageSize, long sinceId, long maxId)
          Retrieves tweets posted by the given user.
 void removeFromFavorites(long id)
          Removes a tweet from the user's collection of favorite tweets.
 void retweet(long tweetId)
          Posts a retweet of an existing tweet.
 Tweet updateStatus(java.lang.String status)
          Updates the user's status.
 Tweet updateStatus(java.lang.String status, org.springframework.core.io.Resource photo)
          Updates the user's status along with a picture.
 Tweet updateStatus(java.lang.String status, org.springframework.core.io.Resource photo, StatusDetails details)
          Updates the user's status, including a picture and additional metadata concerning the status.
 Tweet updateStatus(java.lang.String status, StatusDetails details)
          Updates the user's status, including additional metadata concerning the status.
 

Method Detail

getHomeTimeline

java.util.List<Tweet> getHomeTimeline()
Retrieves the 20 most recently posted tweets, including retweets, from the authenticating user's home timeline. The home timeline includes tweets from the user's timeline and the timeline of anyone that they follow.

Returns:
a collection of Tweets in the authenticating user's home timeline.
Throws:
org.springframework.social.ApiException - if there is an error while communicating with Twitter.
org.springframework.social.MissingAuthorizationException - if TwitterTemplate was not created with OAuth credentials.

getHomeTimeline

java.util.List<Tweet> getHomeTimeline(int pageSize)
Retrieves tweets, including retweets, from the authenticating user's home timeline. The home timeline includes tweets from the user's timeline and the timeline of anyone that they follow.

Parameters:
pageSize - The number of Tweets per page. Should be less than or equal to 200. (Will return at most 200 entries, even if pageSize is greater than 200.)
Returns:
a collection of Tweets in the authenticating user's home timeline.
Throws:
org.springframework.social.ApiException - if there is an error while communicating with Twitter.
org.springframework.social.MissingAuthorizationException - if TwitterTemplate was not created with OAuth credentials.

getHomeTimeline

java.util.List<Tweet> getHomeTimeline(int pageSize,
                                      long sinceId,
                                      long maxId)
Retrieves tweets, including retweets, from the authenticating user's home timeline. The home timeline includes tweets from the user's timeline and the timeline of anyone that they follow.

Parameters:
pageSize - The number of Tweets per page. Should be less than or equal to 200. (Will return at most 200 entries, even if pageSize is greater than 200.)
sinceId - The minimum Tweet ID to return in the results
maxId - The maximum Tweet ID to return in the results
Returns:
a collection of Tweets in the authenticating user's home timeline.
Throws:
org.springframework.social.ApiException - if there is an error while communicating with Twitter.
org.springframework.social.MissingAuthorizationException - if TwitterTemplate was not created with OAuth credentials.

getUserTimeline

java.util.List<Tweet> getUserTimeline()
Retrieves the 20 most recent tweets posted by the authenticating user.

Returns:
a collection of Tweets that have been posted by the authenticating user.
Throws:
org.springframework.social.ApiException - if there is an error while communicating with Twitter.
org.springframework.social.MissingAuthorizationException - if TwitterTemplate was not created with OAuth credentials.

getUserTimeline

java.util.List<Tweet> getUserTimeline(int pageSize)
Retrieves tweets posted by the authenticating user. The most recent tweets are listed first.

Parameters:
pageSize - The number of Tweets per page. Should be less than or equal to 200. (Will return at most 200 entries, even if pageSize is greater than 200.)
Returns:
a collection of Tweets that have been posted by the authenticating user.
Throws:
org.springframework.social.ApiException - if there is an error while communicating with Twitter.
org.springframework.social.MissingAuthorizationException - if TwitterTemplate was not created with OAuth credentials.

getUserTimeline

java.util.List<Tweet> getUserTimeline(int pageSize,
                                      long sinceId,
                                      long maxId)
Retrieves tweets posted by the authenticating user. The most recent tweets are listed first.

Parameters:
pageSize - The number of Tweets per page. Should be less than or equal to 200. (Will return at most 200 entries, even if pageSize is greater than 200.)
sinceId - The minimum Tweet ID to return in the results
maxId - The maximum Tweet ID to return in the results
Returns:
a collection of Tweets that have been posted by the authenticating user.
Throws:
org.springframework.social.ApiException - if there is an error while communicating with Twitter.
org.springframework.social.MissingAuthorizationException - if TwitterTemplate was not created with OAuth credentials.

getUserTimeline

java.util.List<Tweet> getUserTimeline(java.lang.String screenName)
Retrieves the 20 most recent tweets posted by the given user. Supports either user or application authorization.

Parameters:
screenName - The screen name of the user whose timeline is being requested.
Returns:
a collection of Tweets from the specified user's timeline.
Throws:
org.springframework.social.ApiException - if there is an error while communicating with Twitter.
org.springframework.social.MissingAuthorizationException - if TwitterTemplate was not created with OAuth credentials or an application access token.

getUserTimeline

java.util.List<Tweet> getUserTimeline(java.lang.String screenName,
                                      int pageSize)
Retrieves tweets posted by the given user. The most recent tweets are listed first. Supports either user or application authorization.

Parameters:
screenName - The screen name of the user whose timeline is being requested.
pageSize - The number of Tweets per page. Should be less than or equal to 200. (Will return at most 200 entries, even if pageSize is greater than 200.)
Returns:
a collection of Tweets from the specified user's timeline.
Throws:
org.springframework.social.ApiException - if there is an error while communicating with Twitter.
org.springframework.social.MissingAuthorizationException - if TwitterTemplate was not created with OAuth credentials or an application access token.

getUserTimeline

java.util.List<Tweet> getUserTimeline(java.lang.String screenName,
                                      int pageSize,
                                      long sinceId,
                                      long maxId)
Retrieves tweets posted by the given user. The most recent tweets are listed first. Supports either user or application authorization.

Parameters:
screenName - The screen name of the user whose timeline is being requested.
pageSize - The number of Tweets per page. Should be less than or equal to 200. (Will return at most 200 entries, even if pageSize is greater than 200.)
sinceId - The minimum Tweet ID to return in the results
maxId - The maximum Tweet ID to return in the results
Returns:
a collection of Tweets from the specified user's timeline.
Throws:
org.springframework.social.ApiException - if there is an error while communicating with Twitter.
org.springframework.social.MissingAuthorizationException - if TwitterTemplate was not created with OAuth credentials or an application access token.

getUserTimeline

java.util.List<Tweet> getUserTimeline(long userId)
Retrieves the 20 most recent tweets posted by the given user. Supports either user or application authorization.

Parameters:
userId - The user ID of the user whose timeline is being requested.
Returns:
a collection of Tweets from the specified user's timeline.
Throws:
org.springframework.social.ApiException - if there is an error while communicating with Twitter.
org.springframework.social.MissingAuthorizationException - if TwitterTemplate was not created with OAuth credentials or an application access token.

getUserTimeline

java.util.List<Tweet> getUserTimeline(long userId,
                                      int pageSize)
Retrieves tweets posted by the given user. The most recent tweets are listed first. Supports either user or application authorization.

Parameters:
userId - The user ID of the user whose timeline is being requested.
pageSize - The number of Tweets per page. Should be less than or equal to 200. (Will return at most 200 entries, even if pageSize is greater than 200.)
Returns:
a collection of Tweets from the specified user's timeline.
Throws:
org.springframework.social.ApiException - if there is an error while communicating with Twitter.
org.springframework.social.MissingAuthorizationException - if TwitterTemplate was not created with OAuth credentials or an application access token.

getUserTimeline

java.util.List<Tweet> getUserTimeline(long userId,
                                      int pageSize,
                                      long sinceId,
                                      long maxId)
Retrieves tweets posted by the given user. The most recent tweets are listed first. Supports either user or application authorization.

Parameters:
userId - The user ID of the user whose timeline is being requested.
pageSize - The number of Tweets per page. Should be less than or equal to 200. (Will return at most 200 entries, even if pageSize is greater than 200.)
sinceId - The minimum Tweet ID to return in the results
maxId - The maximum Tweet ID to return in the results
Returns:
a collection of Tweets from the specified user's timeline.
Throws:
org.springframework.social.ApiException - if there is an error while communicating with Twitter.
org.springframework.social.MissingAuthorizationException - if TwitterTemplate was not created with OAuth credentials or an application access token.

getRetweetsOfMe

java.util.List<Tweet> getRetweetsOfMe()
Retrieve the 20 most recent tweets of the authenticated user that have been retweeted by others.

Throws:
org.springframework.social.ApiException - if there is an error while communicating with Twitter.
org.springframework.social.MissingAuthorizationException - if TwitterTemplate was not created with OAuth credentials.

getRetweetsOfMe

java.util.List<Tweet> getRetweetsOfMe(int page,
                                      int pageSize)
Retrieve tweets of the authenticated user that have been retweeted by others. The most recent tweets are listed first.

Parameters:
page - The page to return
pageSize - The number of Tweets per page. Should be less than or equal to 100. (Will return at most 100 entries, even if pageSize is greater than 100.)
Throws:
org.springframework.social.ApiException - if there is an error while communicating with Twitter.
org.springframework.social.MissingAuthorizationException - if TwitterTemplate was not created with OAuth credentials.

getRetweetsOfMe

java.util.List<Tweet> getRetweetsOfMe(int page,
                                      int pageSize,
                                      long sinceId,
                                      long maxId)
Retrieve tweets of the authenticated user that have been retweeted by others. The most recent tweets are listed first.

Parameters:
page - The page to return
pageSize - The number of Tweets per page. Should be less than or equal to 100. (Will return at most 100 entries, even if pageSize is greater than 100.)
sinceId - The minimum Tweet ID to return in the results.
maxId - The maximum Tweet ID to return in the results.
Throws:
org.springframework.social.ApiException - if there is an error while communicating with Twitter.
org.springframework.social.MissingAuthorizationException - if TwitterTemplate was not created with OAuth credentials.

getMentions

java.util.List<Tweet> getMentions()
Retrieve the 20 most recent tweets that mention the authenticated user.

Returns:
a collection of Tweet objects that mention the authenticated user.
Throws:
org.springframework.social.ApiException - if there is an error while communicating with Twitter.
org.springframework.social.MissingAuthorizationException - if TwitterTemplate was not created with OAuth credentials.

getMentions

java.util.List<Tweet> getMentions(int pageSize)
Retrieve tweets that mention the authenticated user. The most recent tweets are listed first.

Parameters:
pageSize - The number of Tweets per page. Should be less than or equal to 200. (Will return at most 200 entries, even if pageSize is greater than 200.)
Returns:
a collection of Tweet objects that mention the authenticated user.
Throws:
org.springframework.social.ApiException - if there is an error while communicating with Twitter.
org.springframework.social.MissingAuthorizationException - if TwitterTemplate was not created with OAuth credentials.

getMentions

java.util.List<Tweet> getMentions(int pageSize,
                                  long sinceId,
                                  long maxId)
Retrieve tweets that mention the authenticated user. The most recent tweets are listed first.

Parameters:
pageSize - The number of Tweets per page. Should be less than or equal to 200. (Will return at most 200 entries, even if pageSize is greater than 200.)
sinceId - The minimum Tweet ID to return in the results
maxId - The maximum Tweet ID to return in the results
Returns:
a collection of Tweet objects that mention the authenticated user.
Throws:
org.springframework.social.ApiException - if there is an error while communicating with Twitter.
org.springframework.social.MissingAuthorizationException - if TwitterTemplate was not created with OAuth credentials.

getStatus

Tweet getStatus(long tweetId)
Returns a single tweet. Supports either user or application authorization.

Parameters:
tweetId - the tweet's ID
Throws:
org.springframework.social.ApiException - if there is an error while communicating with Twitter.
org.springframework.social.MissingAuthorizationException - if TwitterTemplate was not created with OAuth credentials or an application access token.

updateStatus

Tweet updateStatus(java.lang.String status)
Updates the user's status.

Parameters:
status - The status message
Throws:
org.springframework.social.ApiException - if there is an error while communicating with Twitter.
DuplicateTweetException - if the status message duplicates a previously posted status.
MessageTooLongException - if the length of the status message exceeds Twitter's 140 character limit.
org.springframework.social.MissingAuthorizationException - if TwitterTemplate was not created with OAuth credentials.

updateStatus

Tweet updateStatus(java.lang.String status,
                   org.springframework.core.io.Resource photo)
Updates the user's status along with a picture.

Parameters:
status - The status message
photo - A Resource for the photo data. The given Resource must implement the getFilename() method (such as FileSystemResource or ClassPathResource) and must contain GIF, JPG, or PNG data.
Throws:
org.springframework.social.ApiException - if there is an error while communicating with Twitter.
DuplicateTweetException - if the status message duplicates a previously posted status.
MessageTooLongException - if the length of the status message exceeds Twitter's 140 character limit.
org.springframework.social.OperationNotPermittedException - if the photo resource isn't a GIF, JPG, or PNG.
org.springframework.social.MissingAuthorizationException - if TwitterTemplate was not created with OAuth credentials.

updateStatus

Tweet updateStatus(java.lang.String status,
                   StatusDetails details)
Updates the user's status, including additional metadata concerning the status.

Parameters:
status - The status message
details - Metadata pertaining to the status
Throws:
org.springframework.social.ApiException - if there is an error while communicating with Twitter.
DuplicateTweetException - if the status message duplicates a previously posted status.
MessageTooLongException - if the length of the status message exceeds Twitter's 140 character limit.
org.springframework.social.MissingAuthorizationException - if TwitterTemplate was not created with OAuth credentials.

updateStatus

Tweet updateStatus(java.lang.String status,
                   org.springframework.core.io.Resource photo,
                   StatusDetails details)
Updates the user's status, including a picture and additional metadata concerning the status.

Parameters:
status - The status message
photo - A Resource for the photo data. The given Resource must implement the getFilename() method (such as FileSystemResource or ClassPathResource) and must contain GIF, JPG, or PNG data.
details - Metadata pertaining to the status
Throws:
org.springframework.social.ApiException - if there is an error while communicating with Twitter.
DuplicateTweetException - if the status message duplicates a previously posted status.
MessageTooLongException - if the length of the status message exceeds Twitter's 140 character limit.
org.springframework.social.OperationNotPermittedException - if the photo resource isn't a GIF, JPG, or PNG.
org.springframework.social.MissingAuthorizationException - if TwitterTemplate was not created with OAuth credentials.

deleteStatus

void deleteStatus(long tweetId)
Removes a status entry.

Parameters:
tweetId - the tweet's ID
Throws:
org.springframework.social.ApiException - if there is an error while communicating with Twitter.
org.springframework.social.MissingAuthorizationException - if TwitterTemplate was not created with OAuth credentials.

retweet

void retweet(long tweetId)
Posts a retweet of an existing tweet.

Parameters:
tweetId - The ID of the tweet to be retweeted
Throws:
org.springframework.social.ApiException - if there is an error while communicating with Twitter.
org.springframework.social.MissingAuthorizationException - if TwitterTemplate was not created with OAuth credentials.

getRetweets

java.util.List<Tweet> getRetweets(long tweetId)
Retrieves up to 100 retweets of a specific tweet. Supports either user or application authorization.

Parameters:
tweetId - the tweet's ID
Throws:
org.springframework.social.ApiException - if there is an error while communicating with Twitter.
org.springframework.social.MissingAuthorizationException - if TwitterTemplate was not created with OAuth credentials or an application access token.

getRetweets

java.util.List<Tweet> getRetweets(long tweetId,
                                  int count)
Retrieves retweets of a specific tweet. Supports either user or application authorization.

Parameters:
tweetId - the tweet's ID
count - The maximum number of retweets to return. Should be less than or equal to 100. (Will return at most 100 entries, even if pageSize is greater than 100.)
Throws:
org.springframework.social.ApiException - if there is an error while communicating with Twitter.
org.springframework.social.MissingAuthorizationException - if TwitterTemplate was not created with OAuth credentials or an application access token.

getFavorites

java.util.List<Tweet> getFavorites()
Retrieves the 20 most recent tweets favorited by the authenticated user.

Returns:
a collection of Tweets from the specified user's favorite timeline.
Throws:
org.springframework.social.ApiException - if there is an error while communicating with Twitter.
org.springframework.social.MissingAuthorizationException - if TwitterTemplate was not created with OAuth credentials.

getFavorites

java.util.List<Tweet> getFavorites(int pageSize)
Retrieves tweets favorited by the authenticated user.

Parameters:
pageSize - The number of entries per page.
Returns:
a collection of Tweets from the specified user's favorite timeline.
Throws:
org.springframework.social.ApiException - if there is an error while communicating with Twitter.
org.springframework.social.MissingAuthorizationException - if TwitterTemplate was not created with OAuth credentials.

getFavorites

java.util.List<Tweet> getFavorites(long userId)
Retrieves the 20 most recent tweets favorited by the specified user. Supports either user or application authorization.

Parameters:
userId - The user ID of the user whose favorites are being requested.
Returns:
a collection of Tweets from the specified user's favorite timeline.
Throws:
org.springframework.social.ApiException - if there is an error while communicating with Twitter.
org.springframework.social.MissingAuthorizationException - if TwitterTemplate was not created with OAuth credentials or an application access token.

getFavorites

java.util.List<Tweet> getFavorites(long userId,
                                   int pageSize)
Retrieves tweets favorited by the specified user. Supports either user or application authorization.

Parameters:
userId - The user ID of the user whose favorites are being requested.
pageSize - The number of entries per page.
Returns:
a collection of Tweets from the specified user's favorite timeline.
Throws:
org.springframework.social.ApiException - if there is an error while communicating with Twitter.
org.springframework.social.MissingAuthorizationException - if TwitterTemplate was not created with OAuth credentials or an application access token.

getFavorites

java.util.List<Tweet> getFavorites(java.lang.String screenName)
Retrieves the 20 most recent tweets favorited by the specified user. Supports either user or application authorization.

Parameters:
screenName - The screen name of the user whose favorites are being requested.
Returns:
a collection of Tweets from the specified user's favorite timeline.
Throws:
org.springframework.social.ApiException - if there is an error while communicating with Twitter.
org.springframework.social.MissingAuthorizationException - if TwitterTemplate was not created with OAuth credentials or an application access token.

getFavorites

java.util.List<Tweet> getFavorites(java.lang.String screenName,
                                   int pageSize)
Retrieves tweets favorited by the specified user. Supports either user or application authorization.

Parameters:
screenName - The screen name of the user whose favorites are being requested.
pageSize - The number of entries per page.
Returns:
a collection of Tweets from the specified user's favorite timeline.
Throws:
org.springframework.social.ApiException - if there is an error while communicating with Twitter.
org.springframework.social.MissingAuthorizationException - if TwitterTemplate was not created with OAuth credentials or an application access token.

addToFavorites

void addToFavorites(long id)
Adds a tweet to the user's collection of favorite tweets.

Parameters:
id - the tweet's ID
Throws:
org.springframework.social.ApiException - if there is an error while communicating with Twitter.
org.springframework.social.MissingAuthorizationException - if TwitterTemplate was not created with OAuth credentials.

removeFromFavorites

void removeFromFavorites(long id)
Removes a tweet from the user's collection of favorite tweets.

Parameters:
id - the tweet's ID
Throws:
org.springframework.social.ApiException - if there is an error while communicating with Twitter.
org.springframework.social.MissingAuthorizationException - if TwitterTemplate was not created with OAuth credentials.

Spring Social Twitter