|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.twitterapime.rest.Timeline
public final class Timeline
This class defines the methods responsible for accessing the main timelines (i.e. public, home, user, mentions and DMs) provided by Twitter.
Credential c = new Credential(...); UserAccountManager uam = UserAccountManager.getInstance(c); if (uam.verifyCredential()) { Timeline ter = Timeline.getInstance(uam); Query q = QueryComposer.count(5); //return only 5 latest tweets. ter.startGetHomeTweets(q, new SearchDeviceListener() { public void searchCompleted() {} public void searchFailed(Throwable cause) {} public void tweetFound(Tweet tweet) { System.out.println(tweet); } }); }
UserAccountManager
,
SearchDeviceListener
,
QueryComposer
Field Summary | |
---|---|
static java.lang.String |
TWITTER_API_URL_SERVICE_DIRECT_MESSAGES
Key for Twitter API URL service direct messages. |
static java.lang.String |
TWITTER_API_URL_SERVICE_DIRECT_MESSAGES_SENT
Key for Twitter API URL service direct messages sent. |
static java.lang.String |
TWITTER_API_URL_SERVICE_STATUSES_HOME_TIMELINE
Key for Twitter API URL service statuses home timeline. |
static java.lang.String |
TWITTER_API_URL_SERVICE_STATUSES_MENTIONS
Key for Twitter API URL service statuses mentions. |
static java.lang.String |
TWITTER_API_URL_SERVICE_STATUSES_PUBLIC_TIMELINE
Key for Twitter API URL service statuses public timeline. |
static java.lang.String |
TWITTER_API_URL_SERVICE_STATUSES_USER_TIMELINE
Key for Twitter API URL service statuses user timeline. |
Method Summary | |
---|---|
static Timeline |
getInstance()
Get a single instance of Timeline class, which is NOT associated to any user account. |
static Timeline |
getInstance(UserAccountManager uam)
Get an instance of Timeline class and associate it to a given user account. |
void |
setServiceURL(java.lang.String serviceKey,
java.lang.String url)
Set a new URL to a given Twitter API service. |
void |
startGetDirectMessages(Query q,
boolean received,
SearchDeviceListener l)
Get all Direct Messages from/to the authenticating user according to given filter. |
void |
startGetHomeTweets(Query q,
SearchDeviceListener l)
Get most recent tweets, including retweets, posted by the authenticating user and the user's friends according to given filter. |
void |
startGetMentions(Query q,
SearchDeviceListener l)
Get most recent mentions (status containing @username) for the authenticating user according to given filter. |
void |
startGetPublicTweets(SearchDeviceListener l)
Get most recent tweets from non-protected users who have set a custom user icon. |
void |
startGetUserTweets(Query q,
SearchDeviceListener l)
Get most recent tweets posted from the authenticating user and that user's friends according to given filter. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String TWITTER_API_URL_SERVICE_STATUSES_PUBLIC_TIMELINE
Key for Twitter API URL service statuses public timeline.
setServiceURL(String, String)
,
startGetPublicTweets(SearchDeviceListener)
,
Constant Field Valuespublic static final java.lang.String TWITTER_API_URL_SERVICE_STATUSES_HOME_TIMELINE
Key for Twitter API URL service statuses home timeline.
setServiceURL(String, String)
,
startGetHomeTweets(Query, SearchDeviceListener)
,
Constant Field Valuespublic static final java.lang.String TWITTER_API_URL_SERVICE_STATUSES_USER_TIMELINE
Key for Twitter API URL service statuses user timeline.
setServiceURL(String, String)
,
startGetUserTweets(Query, SearchDeviceListener)
,
Constant Field Valuespublic static final java.lang.String TWITTER_API_URL_SERVICE_STATUSES_MENTIONS
Key for Twitter API URL service statuses mentions.
setServiceURL(String, String)
,
startGetMentions(Query, SearchDeviceListener)
,
Constant Field Valuespublic static final java.lang.String TWITTER_API_URL_SERVICE_DIRECT_MESSAGES
Key for Twitter API URL service direct messages.
setServiceURL(String, String)
,
startGetDirectMessages(Query, boolean, SearchDeviceListener)
,
Constant Field Valuespublic static final java.lang.String TWITTER_API_URL_SERVICE_DIRECT_MESSAGES_SENT
Key for Twitter API URL service direct messages sent.
setServiceURL(String, String)
,
startGetDirectMessages(Query, boolean, SearchDeviceListener)
,
Constant Field ValuesMethod Detail |
---|
public void setServiceURL(java.lang.String serviceKey, java.lang.String url)
Set a new URL to a given Twitter API service. This method is very useful in case Twitter API decides to change a service's URL. So there is no need to wait for a new version of this API to get it working back.
Be careful about using this method, since it can cause unexpected results, case you enter an invalid URL.
serviceKey
- Service key.url
- New URL.TWITTER_API_URL_SERVICE_DIRECT_MESSAGES
,
TWITTER_API_URL_SERVICE_DIRECT_MESSAGES_SENT
,
TWITTER_API_URL_SERVICE_STATUSES_HOME_TIMELINE
,
TWITTER_API_URL_SERVICE_STATUSES_MENTIONS
,
TWITTER_API_URL_SERVICE_STATUSES_PUBLIC_TIMELINE
,
TWITTER_API_URL_SERVICE_STATUSES_USER_TIMELINE
public static Timeline getInstance(UserAccountManager uam)
Get an instance of Timeline class and associate it to a given user account.
uam
- User account manager.
java.lang.IllegalArgumentException
- If UserAccountManager is null.
java.lang.SecurityException
- If UserAccountManager is not verified.public static Timeline getInstance()
Get a single instance of Timeline class, which is NOT associated to any user account.
public void startGetPublicTweets(SearchDeviceListener l)
Get most recent tweets from non-protected users who have set a custom user icon.
This method does not wait for the search process is completed to return. To have access to this search's result, a SearchDeviceListener object must be registered.
l
- Listener object to be notified about the search's result.
java.lang.IllegalArgumentException
- If listener is null.public void startGetHomeTweets(Query q, SearchDeviceListener l)
Get most recent tweets, including retweets, posted by the authenticating user and the user's friends according to given filter. This is the equivalent to timeline home on the Web.
This method does not wait for the search process is completed to return. To have access to this search's result, a SearchDeviceListener object must be registered.
In order to create the query, only the following methods can be used as filters:
QueryComposer.sinceID(String)
QueryComposer.maxID(String)
QueryComposer.count(int)
QueryComposer.page(int)
q
- The filter query. If null all tweets are returned.l
- Listener object to be notified about the search's result.
java.lang.SecurityException
- If it is not authenticated.
java.lang.IllegalArgumentException
- If listener is null.public void startGetUserTweets(Query q, SearchDeviceListener l)
Get most recent tweets posted from the authenticating user and that user's friends according to given filter. This is the equivalent of the Web user page for your own user.
This method does not wait for the search process is completed to return. To have access to this search's result, a SearchDeviceListener object must be registered.
In order to create the query, only the following methods can be used as filters:
QueryComposer.sinceID(String)
QueryComposer.maxID(String)
QueryComposer.count(int)
QueryComposer.page(int)
q
- The filter query. If null all tweets are returned.l
- Listener object to be notified about the search's result.
java.lang.SecurityException
- If it is not authenticated.
java.lang.IllegalArgumentException
- If listener is null.public void startGetMentions(Query q, SearchDeviceListener l)
Get most recent mentions (status containing @username) for the authenticating user according to given filter.
This method does not wait for the search process is completed to return. To have access to this search's result, a SearchDeviceListener object must be registered.
In order to create the query, only the following methods can be used as filters:
QueryComposer.sinceID(String)
QueryComposer.maxID(String)
QueryComposer.count(int)
QueryComposer.page(int)
q
- The filter query. If null all tweets are returned.l
- Listener object to be notified about the search's result.
java.lang.SecurityException
- If it is not authenticated.
java.lang.IllegalArgumentException
- If listener is null.public void startGetDirectMessages(Query q, boolean received, SearchDeviceListener l)
Get all Direct Messages from/to the authenticating user according to given filter.
This method does not wait for the search process is completed to return. To have access to this search's result, a SearchDeviceListener object must be registered.
In order to create the query, only the following methods can be used as filters:
QueryComposer.sinceID(String)
QueryComposer.maxID(String)
QueryComposer.count(int)
QueryComposer.page(int)
q
- The filter query. If null all DMs are returned.l
- Listener object to be notified about the search's result.received
- Return received DMs (true), otherwise, sent ones.
java.lang.SecurityException
- If it is not authenticated.
java.lang.IllegalArgumentException
- If listener is null.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |