|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.social.twitter.TwitterTemplate
public class TwitterTemplate
This is the central class for interacting with Twitter.
Most (not all) Twitter operations require OAuth authentication. To perform
such operations, TwitterTemplate
must be constructed with the minimal
amount of information required to sign requests to Twitter's API with an
OAuth Authorization
header.
There are a few operations, such as searching, that do not require OAuth
authentication. In those cases, you may use a TwitterTemplate
that is
created through the default constructor and without any OAuth details.
Attempts to perform secured operations through such an instance, however,
will result in AccountNotConnectedException
being thrown.
Constructor Summary | |
---|---|
TwitterTemplate()
Create a new instance of TwitterTemplate. |
|
TwitterTemplate(java.lang.String apiKey,
java.lang.String apiSecret,
java.lang.String accessToken,
java.lang.String accessTokenSecret)
Create a new instance of TwitterTemplate. |
Method Summary | |
---|---|
java.util.List<java.lang.String> |
getFriends(java.lang.String screenName)
Retrieves a list of users that the given user follows. |
java.lang.String |
getProfileId()
Retrieves the user's Twitter screen name. |
void |
retweet(long tweetId)
Posts a retweet of an existing tweet. |
SearchResults |
search(java.lang.String query)
Searches Twitter, returning the first 50 matching Tweet s |
SearchResults |
search(java.lang.String query,
int page,
int resultsPerPage)
Searches Twitter, returning a specific page out of the complete set of results. |
SearchResults |
search(java.lang.String query,
int page,
int resultsPerPage,
int sinceId,
int maxId)
Searches Twitter, returning a specific page out of the complete set of results. |
void |
updateStatus(java.lang.String message)
Updates the user's status. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public TwitterTemplate()
AccountNotConnectedException
.
public TwitterTemplate(java.lang.String apiKey, java.lang.String apiSecret, java.lang.String accessToken, java.lang.String accessTokenSecret)
RestOperations
internally using this information.
apiKey
- the application's API key.apiSecret
- the application's API secret.accessToken
- the user's access token, given after successful OAuth
authentication.accessTokenSecret
- the access token secret, given along with the access token
after successful OAuth authentication.Method Detail |
---|
public java.lang.String getProfileId()
TwitterOperations
getProfileId
in interface TwitterOperations
public java.util.List<java.lang.String> getFriends(java.lang.String screenName)
TwitterOperations
getFriends
in interface TwitterOperations
screenName
- The user's Twitter screen name
public void updateStatus(java.lang.String message)
TwitterOperations
updateStatus
in interface TwitterOperations
message
- The status messagepublic void retweet(long tweetId)
TwitterOperations
retweet
in interface TwitterOperations
tweetId
- The ID of the tweet to be retweetedpublic SearchResults search(java.lang.String query)
TwitterOperations
Tweet
s
search
in interface TwitterOperations
query
- The search query string
SearchResults
containing the search results metadata
and a list of matching Tweet
sSearchResults, {@link Tweet}
public SearchResults search(java.lang.String query, int page, int resultsPerPage)
TwitterOperations
search
in interface TwitterOperations
query
- The search query stringpage
- The page to returnresultsPerPage
- The number of Tweet
s per page
SearchResults
containing the search results metadata
and a list of matching Tweet
sSearchResults, {@link Tweet}
public SearchResults search(java.lang.String query, int page, int resultsPerPage, int sinceId, int maxId)
TwitterOperations
search
in interface TwitterOperations
query
- The search query stringpage
- The page to returnsinceId
- The minimum Tweet
ID to return in the resultsmaxId
- The maximum Tweet
ID to return in the results
SearchResults
containing the search results metadata
and a list of matching Tweet
sSearchResults, {@link Tweet}
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |