org.mule.twitter
Class TwitterConnector

java.lang.Object
  extended by org.mule.twitter.TwitterConnector
All Implemented Interfaces:
org.mule.api.context.MuleContextAware, org.mule.api.lifecycle.Initialisable

@Connector(namespacePrefix="twitter")
public class TwitterConnector
extends Object
implements org.mule.api.lifecycle.Initialisable, org.mule.api.context.MuleContextAware

A Connector for Twitter which uses twitter4j.


Field Summary
protected  org.apache.commons.logging.Log logger
           
 
Fields inherited from interface org.mule.api.lifecycle.Initialisable
PHASE_NAME
 
Constructor Summary
TwitterConnector()
           
 
Method Summary
 twitter4j.Status destroyStatus(long statusId)
          Destroys the status specified by the required ID parameter.
Usage note: The authenticating user must be the author of the specified status.
 twitter4j.ResponseList<twitter4j.Status> getHomeTimeline(int page, int count, int sinceId)
          Returns the 20 most recent statuses, including retweets, posted by the authenticating user and that user's friends.
 twitter4j.ResponseList<twitter4j.Status> getMentions(int page, int count, int sinceId)
          Returns the 20 most recent mentions (status containing @username) for the authenticating user.
protected  twitter4j.Paging getPaging(int page, int count, long sinceId)
           
 twitter4j.ResponseList<twitter4j.Status> getPublicTimeline()
          Returns the 20 most recent statuses from non-protected users who have set a custom user icon.
 twitter4j.ResponseList<twitter4j.User> getRetweetedBy(long statusId, int page, int count, int sinceId)
          Show user objects of up to 100 members who retweeted the status.
 twitter4j.IDs getRetweetedByIDs(long statusId, int page, int count, int sinceId)
          Show user ids of up to 100 users who retweeted the status represented by id
This method calls http://api.twitter.com/1/statuses/:id/retweeted_by/ids.format
 twitter4j.ResponseList<twitter4j.Status> getRetweetedByMe(int page, int count, int sinceId)
          Returns the 20 most recent retweets posted by the authenticating user.
 twitter4j.ResponseList<twitter4j.Status> getRetweetedByUserByScreenName(String screenName, int page, int count, int sinceId)
          Returns the 20 most recent retweets posted by the specified user.
 twitter4j.ResponseList<twitter4j.Status> getRetweetedByUserByUserId(long userId, int page, int count, int sinceId)
          Returns the 20 most recent retweets posted by the specified user.
 twitter4j.ResponseList<twitter4j.Status> getRetweetedToMe(int page, int count, int sinceId)
          Returns the 20 most recent retweets posted by the authenticating user's friends.
 twitter4j.ResponseList<twitter4j.Status> getRetweetedToUserByScreenName(String screenName, int page, int count, int sinceId)
          Returns the 20 most recent retweets posted by users the specified user follows.
 twitter4j.ResponseList<twitter4j.Status> getRetweetedToUserByUserId(long userId, int page, int count, int sinceId)
          Returns the 20 most recent retweets posted by users the specified user follows.
 twitter4j.ResponseList<twitter4j.Status> getRetweets(long statusId)
          Returns up to 100 of the first retweets of a given tweet.
 twitter4j.ResponseList<twitter4j.Status> getRetweetsOfMe(int page, int count, int sinceId)
          Returns the 20 most recent tweets of the authenticated user that have been retweeted by others.
 twitter4j.Twitter getTwitterClient()
           
 twitter4j.ResponseList<twitter4j.Status> getUserTimeline(int page, int count, int sinceId)
          Returns the 20 most recent statuses posted from the authenticating user.
 twitter4j.ResponseList<twitter4j.Status> getUserTimelineByScreenName(String screenName, int page, int count, int sinceId)
          Returns the 20 most recent statuses posted from the authenticating user.
 twitter4j.ResponseList<twitter4j.Status> getUserTimelineByUserId(long userId, int page, int count, int sinceId)
          Returns the 20 most recent statuses posted from the authenticating user.
 boolean getUseSSL()
           
 void initialise()
           
 String requestAuthorization(String callbackUrl)
          Start the OAuth request authorization process.
 twitter4j.Status retweetStatus(long statusId)
          Retweets a tweet.
 twitter4j.QueryResult search(String query)
          Returns tweets that match a specified query.
 void setAccessToken(String accessToken)
           
 void setAccessTokenSecret(String accessTokenSecret)
           
 void setConsumerKey(String consumerKey)
           
 void setConsumerSecret(String consumerSecret)
           
 void setMuleContext(org.mule.api.MuleContext context)
           
 void setOauthVerifier(String oauthVerifier)
          Set the OAuth verifier after it has been retrieved via requestAuthorization.
 void setUseSSL(boolean useSSL)
           
 twitter4j.Status showStatus(long id)
          Returns a single status, specified by the id parameter below.
 twitter4j.Status updateStatus(String status, long inReplyTo, twitter4j.GeoLocation geoLocation)
          Updates the authenticating user's status.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected transient org.apache.commons.logging.Log logger
Constructor Detail

TwitterConnector

public TwitterConnector()
Method Detail

initialise

public void initialise()
                throws org.mule.api.lifecycle.InitialisationException
Specified by:
initialise in interface org.mule.api.lifecycle.Initialisable
Throws:
org.mule.api.lifecycle.InitialisationException

search

@Operation
public twitter4j.QueryResult search(String query)
                             throws twitter4j.TwitterException
Returns tweets that match a specified query.

This method calls http://search.twitter.com/search.json

Parameters:
query - The search query.
Returns:
Throws:
twitter4j.TwitterException

getPublicTimeline

@Operation
public twitter4j.ResponseList<twitter4j.Status> getPublicTimeline()
                                                           throws twitter4j.TwitterException
Returns the 20 most recent statuses from non-protected users who have set a custom user icon. The public timeline is cached for 60 seconds and requesting it more often than that is unproductive and a waste of resources.
This method calls http://api.twitter.com/1/statuses/public_timeline

Returns:
list of statuses of the Public Timeline
Throws:
twitter4j.TwitterException - when Twitter service or network is unavailable
See Also:
GET statuses/public_timeline | dev.twitter.com

getHomeTimeline

@Operation
public twitter4j.ResponseList<twitter4j.Status> getHomeTimeline(@Parameter(defaultValue="1",optional=true)
                                                                          int page,
                                                                          @Parameter(defaultValue="100",optional=true)
                                                                          int count,
                                                                          @Parameter(defaultValue="-1",optional=true)
                                                                          int sinceId)
                                                         throws twitter4j.TwitterException
Returns the 20 most recent statuses, including retweets, posted by the authenticating user and that user's friends. This is the equivalent of /timeline/home on the Web.
Usage note: This home_timeline call is identical to statuses/friends_timeline, except that home_timeline also contains retweets, while statuses/friends_timeline does not for backwards compatibility reasons. In a future version of the API, statuses/friends_timeline will be deprected and replaced by home_timeline.
This method calls http://api.twitter.com/1/statuses/home_timeline

Parameters:
paging - controls pagination. Supports since_id, max_id, count and page parameters.
Returns:
list of the home Timeline
Throws:
twitter4j.TwitterException - when Twitter service or network is unavailable
See Also:
GET statuses/home_timeline | dev.twitter.com

getUserTimelineByScreenName

@Operation
public twitter4j.ResponseList<twitter4j.Status> getUserTimelineByScreenName(String screenName,
                                                                                      @Parameter(defaultValue="1",optional=true)
                                                                                      int page,
                                                                                      @Parameter(defaultValue="100",optional=true)
                                                                                      int count,
                                                                                      @Parameter(defaultValue="-1",optional=true)
                                                                                      int sinceId)
                                                                     throws twitter4j.TwitterException
Returns the 20 most recent statuses posted from the authenticating user. It's also possible to request another user's timeline via the id parameter.
This is the equivalent of the Web / page for your own user, or the profile page for a third party.
For backwards compatibility reasons, retweets are stripped out of the user_timeline when calling in XML or JSON (they appear with 'RT' in RSS and Atom). If you'd like them included, you can merge them in from statuses retweeted_by_me.

This method calls http://api.twitter.com/1/statuses/user_timeline.json

Parameters:
screenName - specifies the screen name of the user for whom to return the user_timeline
Returns:
list of the user Timeline
Throws:
twitter4j.TwitterException - when Twitter service or network is unavailable
See Also:
GET statuses/user_timeline | dev.twitter.com

getUserTimelineByUserId

@Operation
public twitter4j.ResponseList<twitter4j.Status> getUserTimelineByUserId(long userId,
                                                                                  @Parameter(defaultValue="1",optional=true)
                                                                                  int page,
                                                                                  @Parameter(defaultValue="100",optional=true)
                                                                                  int count,
                                                                                  @Parameter(defaultValue="-1",optional=true)
                                                                                  int sinceId)
                                                                 throws twitter4j.TwitterException
Returns the 20 most recent statuses posted from the authenticating user. It's also possible to request another user's timeline via the id parameter.
This is the equivalent of the Web / page for your own user, or the profile page for a third party.
For backwards compatibility reasons, retweets are stripped out of the user_timeline when calling in XML or JSON (they appear with 'RT' in RSS and Atom). If you'd like them included, you can merge them in from statuses retweeted_by_me.

This method calls http://api.twitter.com/1/statuses/user_timeline.json

Parameters:
userId - specifies the ID of the user for whom to return the user_timeline
paging - controls pagination. Supports since_id, max_id, count and page parameters.
Returns:
list of the user Timeline
Throws:
twitter4j.TwitterException - when Twitter service or network is unavailable
See Also:
GET statuses/user_timeline | dev.twitter.com

getPaging

protected twitter4j.Paging getPaging(int page,
                                     int count,
                                     long sinceId)

getUserTimeline

@Operation
public twitter4j.ResponseList<twitter4j.Status> getUserTimeline(@Parameter(defaultValue="1",optional=true)
                                                                          int page,
                                                                          @Parameter(defaultValue="100",optional=true)
                                                                          int count,
                                                                          @Parameter(defaultValue="-1",optional=true)
                                                                          int sinceId)
                                                         throws twitter4j.TwitterException
Returns the 20 most recent statuses posted from the authenticating user. It's also possible to request another user's timeline via the id parameter.
This is the equivalent of the Web / page for your own user, or the profile page for a third party.
For backwards compatibility reasons, retweets are stripped out of the user_timeline when calling in XML or JSON (they appear with 'RT' in RSS and Atom). If you'd like them included, you can merge them in from statuses retweeted_by_me.

This method calls http://api.twitter.com/1/statuses/user_timeline.json

Parameters:
userId - specifies the ID of the user for whom to return the user_timeline
paging - controls pagination. Supports since_id, max_id, count and page parameters.
Returns:
list of the user Timeline
Throws:
twitter4j.TwitterException - when Twitter service or network is unavailable
See Also:
GET statuses/user_timeline | dev.twitter.com

getMentions

@Operation
public twitter4j.ResponseList<twitter4j.Status> getMentions(@Parameter(defaultValue="1",optional=true)
                                                                      int page,
                                                                      @Parameter(defaultValue="100",optional=true)
                                                                      int count,
                                                                      @Parameter(defaultValue="-1",optional=true)
                                                                      int sinceId)
                                                     throws twitter4j.TwitterException
Returns the 20 most recent mentions (status containing @username) for the authenticating user.
This method calls http://api.twitter.com/1/statuses/mentions

Parameters:
paging - controls pagination. Supports since_id, max_id, count and page parameters.
Returns:
the 20 most recent replies
Throws:
twitter4j.TwitterException - when Twitter service or network is unavailable
See Also:
GET statuses/mentions | dev.twitter.com

getRetweetedByMe

@Operation
public twitter4j.ResponseList<twitter4j.Status> getRetweetedByMe(@Parameter(defaultValue="1",optional=true)
                                                                           int page,
                                                                           @Parameter(defaultValue="100",optional=true)
                                                                           int count,
                                                                           @Parameter(defaultValue="-1",optional=true)
                                                                           int sinceId)
                                                          throws twitter4j.TwitterException
Returns the 20 most recent retweets posted by the authenticating user.
This method calls http://api.twitter.com/1/statuses/retweeted_by_me

Returns:
the 20 most recent retweets posted by the authenticating user
Throws:
twitter4j.TwitterException - when Twitter service or network is unavailable
See Also:
GET statuses/retweeted_by_me | dev.twitter.com

getRetweetedToMe

@Operation
public twitter4j.ResponseList<twitter4j.Status> getRetweetedToMe(@Parameter(defaultValue="1",optional=true)
                                                                           int page,
                                                                           @Parameter(defaultValue="100",optional=true)
                                                                           int count,
                                                                           @Parameter(defaultValue="-1",optional=true)
                                                                           int sinceId)
                                                          throws twitter4j.TwitterException
Returns the 20 most recent retweets posted by the authenticating user's friends.
This method calls http://api.twitter.com/1/statuses/retweeted_to_me

Parameters:
paging - controls pagination. Supports since_id, max_id, count and page parameters.
Returns:
the 20 most recent retweets posted by the authenticating user's friends.
Throws:
twitter4j.TwitterException - when Twitter service or network is unavailable
See Also:
GET statuses/retweeted_to_me | dev.twitter.com

getRetweetsOfMe

@Operation
public twitter4j.ResponseList<twitter4j.Status> getRetweetsOfMe(@Parameter(defaultValue="1",optional=true)
                                                                          int page,
                                                                          @Parameter(defaultValue="100",optional=true)
                                                                          int count,
                                                                          @Parameter(defaultValue="-1",optional=true)
                                                                          int sinceId)
                                                         throws twitter4j.TwitterException
Returns the 20 most recent tweets of the authenticated user that have been retweeted by others.
This method calls http://api.twitter.com/1/statuses/retweets_of_me

Parameters:
paging - controls pagination. Supports since_id, max_id, count and page parameters.
Returns:
the 20 most recent tweets of the authenticated user that have been retweeted by others.
Throws:
twitter4j.TwitterException - when Twitter service or network is unavailable
See Also:
GET statuses/retweets_of_me | dev.twitter.com

getRetweetedToUserByScreenName

@Operation
public twitter4j.ResponseList<twitter4j.Status> getRetweetedToUserByScreenName(String screenName,
                                                                                         @Parameter(defaultValue="1",optional=true)
                                                                                         int page,
                                                                                         @Parameter(defaultValue="100",optional=true)
                                                                                         int count,
                                                                                         @Parameter(defaultValue="-1",optional=true)
                                                                                         int sinceId)
                                                                        throws twitter4j.TwitterException
Returns the 20 most recent retweets posted by users the specified user follows. This method is identical to statuses/retweeted_to_me except you can choose the user to view.
This method has not been finalized and the interface is subject to change in incompatible ways.
This method calls http://api.twitter.com/1/statuses/retweeted_to_user

Parameters:
screenName - the user to view
paging - controls pagination. Supports since_id, max_id, count and page parameters.
Returns:
the 20 most recent retweets posted by the authenticating user's friends.
Throws:
twitter4j.TwitterException - when Twitter service or network is unavailable
See Also:
#newtwitter and the API - Twitter API Announcements | Google Group

getRetweetedToUserByUserId

@Operation
public twitter4j.ResponseList<twitter4j.Status> getRetweetedToUserByUserId(long userId,
                                                                                     @Parameter(defaultValue="1",optional=true)
                                                                                     int page,
                                                                                     @Parameter(defaultValue="100",optional=true)
                                                                                     int count,
                                                                                     @Parameter(defaultValue="-1",optional=true)
                                                                                     int sinceId)
                                                                    throws twitter4j.TwitterException
Returns the 20 most recent retweets posted by users the specified user follows. This method is identical to statuses/retweeted_to_me except you can choose the user to view.
This method has not been finalized and the interface is subject to change in incompatible ways.
This method calls http://api.twitter.com/1/statuses/retweeted_to_user

Parameters:
userId - the user to view
paging - controls pagination. Supports since_id, max_id, count and page parameters.
Returns:
the 20 most recent retweets posted by the authenticating user's friends.
Throws:
twitter4j.TwitterException - when Twitter service or network is unavailable
See Also:
#newtwitter and the API - Twitter API Announcements | Google Group

getRetweetedByUserByScreenName

@Operation
public twitter4j.ResponseList<twitter4j.Status> getRetweetedByUserByScreenName(String screenName,
                                                                                         @Parameter(defaultValue="1",optional=true)
                                                                                         int page,
                                                                                         @Parameter(defaultValue="100",optional=true)
                                                                                         int count,
                                                                                         @Parameter(defaultValue="-1",optional=true)
                                                                                         int sinceId)
                                                                        throws twitter4j.TwitterException
Returns the 20 most recent retweets posted by the specified user. This method is identical to statuses/retweeted_by_me except you can choose the user to view.
This method has not been finalized and the interface is subject to change in incompatible ways.
This method calls http://api.twitter.com/1/statuses/retweeted_by_user

Parameters:
screenName - the user to view
paging - controls pagination. Supports since_id, max_id, count and page parameters.
Returns:
the 20 most recent retweets posted by the authenticating user
Throws:
twitter4j.TwitterException - when Twitter service or network is unavailable
See Also:
#newtwitter and the API - Twitter API Announcements | Google Group

getRetweetedByUserByUserId

@Operation
public twitter4j.ResponseList<twitter4j.Status> getRetweetedByUserByUserId(long userId,
                                                                                     @Parameter(defaultValue="1",optional=true)
                                                                                     int page,
                                                                                     @Parameter(defaultValue="100",optional=true)
                                                                                     int count,
                                                                                     @Parameter(defaultValue="-1",optional=true)
                                                                                     int sinceId)
                                                                    throws twitter4j.TwitterException
Returns the 20 most recent retweets posted by the specified user. This method is identical to statuses/retweeted_by_me except you can choose the user to view.
This method has not been finalized and the interface is subject to change in incompatible ways.
This method calls http://api.twitter.com/1/statuses/retweeted_by_user

Parameters:
userId - the user to view
paging - controls pagination. Supports since_id, max_id, count and page parameters.
Returns:
the 20 most recent retweets posted by the authenticating user
Throws:
twitter4j.TwitterException - when Twitter service or network is unavailable
See Also:
#newtwitter and the API - Twitter API Announcements | Google Group

showStatus

@Operation
public twitter4j.Status showStatus(long id)
                            throws twitter4j.TwitterException
Returns a single status, specified by the id parameter below. The status's author will be returned inline.
This method calls http://api.twitter.com/1/statuses/show

Parameters:
id - the numerical ID of the status you're trying to retrieve
Returns:
a single status
Throws:
twitter4j.TwitterException - when Twitter service or network is unavailable
See Also:
GET statuses/show/:id | dev.twitter.com

updateStatus

@Operation
public twitter4j.Status updateStatus(String status,
                                               @Parameter(optional=true,defaultValue="-1")
                                               long inReplyTo,
                                               @Parameter(optional=true)
                                               twitter4j.GeoLocation geoLocation)
                              throws twitter4j.TwitterException
Updates the authenticating user's status. A status update with text identical to the authenticating user's text identical to the authenticating user's current status will be ignored to prevent duplicates.
This method calls http://api.twitter.com/1/statuses/update

Parameters:
status - the text of your status update
Returns:
the latest status
Throws:
twitter4j.TwitterException - when Twitter service or network is unavailable
See Also:
POST statuses/update | dev.twitter.com

destroyStatus

@Operation
public twitter4j.Status destroyStatus(long statusId)
                               throws twitter4j.TwitterException
Destroys the status specified by the required ID parameter.
Usage note: The authenticating user must be the author of the specified status.
This method calls http://api.twitter.com/1/statuses/destroy

Parameters:
statusId - The ID of the status to destroy.
Returns:
the deleted status
Throws:
twitter4j.TwitterException - when Twitter service or network is unavailable
See Also:
POST statuses/destroy/:id | dev.twitter.com

retweetStatus

@Operation
public twitter4j.Status retweetStatus(long statusId)
                               throws twitter4j.TwitterException
Retweets a tweet. Returns the original tweet with retweet details embedded.
This method calls http://api.twitter.com/1/statuses/retweet

Parameters:
statusId - The ID of the status to retweet.
Returns:
the retweeted status
Throws:
twitter4j.TwitterException - when Twitter service or network is unavailable
See Also:
POST statuses/retweet/:id | dev.twitter.com

getRetweets

@Operation
public twitter4j.ResponseList<twitter4j.Status> getRetweets(long statusId)
                                                     throws twitter4j.TwitterException
Returns up to 100 of the first retweets of a given tweet.
This method calls http://api.twitter.com/1/statuses/retweets

Parameters:
statusId - The numerical ID of the tweet you want the retweets of.
Returns:
the retweets of a given tweet
Throws:
twitter4j.TwitterException - when Twitter service or network is unavailable
Since:
Twitter4J 2.0.10
See Also:
Tweets Resources › statuses/retweets/:id

getRetweetedBy

@Operation
public twitter4j.ResponseList<twitter4j.User> getRetweetedBy(long statusId,
                                                                       @Parameter(defaultValue="1",optional=true)
                                                                       int page,
                                                                       @Parameter(defaultValue="100",optional=true)
                                                                       int count,
                                                                       @Parameter(defaultValue="-1",optional=true)
                                                                       int sinceId)
                                                      throws twitter4j.TwitterException
Show user objects of up to 100 members who retweeted the status.
This method calls http://api.twitter.com/1/statuses/:id/retweeted_by

Parameters:
statusId - The ID of the status you want to get retweeters of
paging - controls pagination. Supports count and page parameters.
Returns:
the list of users who retweeted your status
Throws:
twitter4j.TwitterException - when Twitter service or network is unavailable
See Also:
GET statuses/:id/retweeted_by | dev.twitter.com

getRetweetedByIDs

@Operation
public twitter4j.IDs getRetweetedByIDs(long statusId,
                                                 @Parameter(defaultValue="1",optional=true)
                                                 int page,
                                                 @Parameter(defaultValue="100",optional=true)
                                                 int count,
                                                 @Parameter(defaultValue="-1",optional=true)
                                                 int sinceId)
                                throws twitter4j.TwitterException
Show user ids of up to 100 users who retweeted the status represented by id
This method calls http://api.twitter.com/1/statuses/:id/retweeted_by/ids.format

Parameters:
statusId - The ID of the status you want to get retweeters of
paging - controls pagination. Supports count and page parameters.
Returns:
IDs of users who retweeted the stats
Throws:
twitter4j.TwitterException - when Twitter service or network is unavailable
See Also:
GET statuses/:id/retweeted_by/ids | dev.twitter.com

setOauthVerifier

@Operation
public void setOauthVerifier(String oauthVerifier)
                      throws twitter4j.TwitterException
Set the OAuth verifier after it has been retrieved via requestAuthorization. The resulting access tokens will be logged to the INFO level so the user can reuse them as part of the configuration in the future if desired.

Parameters:
oauthVerifier - The OAuth verifier code from Twitter.
Throws:
twitter4j.TwitterException

requestAuthorization

@Operation
public String requestAuthorization(@Parameter(optional=true)
                                             String callbackUrl)
                            throws twitter4j.TwitterException
Start the OAuth request authorization process. This will request a token from Yammer and return a URL which the user can visit to authorize the connector for their account.

Returns:
The user authorization URL.
Throws:
twitter4j.TwitterException

getTwitterClient

public twitter4j.Twitter getTwitterClient()

getUseSSL

public boolean getUseSSL()

setUseSSL

public void setUseSSL(boolean useSSL)

setAccessToken

public void setAccessToken(String accessToken)

setAccessTokenSecret

public void setAccessTokenSecret(String accessTokenSecret)

setConsumerKey

public void setConsumerKey(String consumerKey)

setConsumerSecret

public void setConsumerSecret(String consumerSecret)

setMuleContext

public void setMuleContext(org.mule.api.MuleContext context)
Specified by:
setMuleContext in interface org.mule.api.context.MuleContextAware


Copyright © 2011. All Rights Reserved.