|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.twitterapime.rest.TweetER
public final class TweetER
This class defines the methods responsible for managing (e.g. post, retrieve, etc) tweets.
Credential c = new Credential(...); UserAccountManager uam = UserAccountManager.getInstance(c); if (uam.verifyCredential()) { TweetER ter = TweetER.getInstance(uam); Tweet t = ter.post(new Tweet("status message")); } ... TweetER ter = TweetER.getInstance(); Tweet t = ter.findByID("12635687984");
Tweet
,
UserAccountManager
Field Summary | |
---|---|
static java.lang.String |
TWITTER_API_URL_SERVICE_DIRECT_MESSAGES_NEW
Key for Twitter API URL service direct messages new. |
static java.lang.String |
TWITTER_API_URL_SERVICE_STATUSES_RETWEET
Key for Twitter API URL service statuses retweet. |
static java.lang.String |
TWITTER_API_URL_SERVICE_STATUSES_SHOW
Key for Twitter API URL service statuses show. |
static java.lang.String |
TWITTER_API_URL_SERVICE_STATUSES_UPDATE
Key for Twitter API URL service statuses update. |
Method Summary | |
---|---|
Tweet |
findByID(java.lang.String id)
Find the tweet associated to the given ID. |
static TweetER |
getInstance()
Get a single instance of TweetER class, which is NOT associated to any user account. |
static TweetER |
getInstance(UserAccountManager uam)
Get an instance of TweetER class and associate it to a given user account. |
Tweet |
post(Tweet tweet)
Post a given tweet to Twitter. |
Tweet |
repost(Tweet tweet)
Repost a given tweet to Twitter. |
Tweet |
send(Tweet dm)
Send a given Direct Message to a given recipient. |
void |
setServiceURL(java.lang.String serviceKey,
java.lang.String url)
Set a new URL to a given Twitter API service. |
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_UPDATE
Key for Twitter API URL service statuses update.
setServiceURL(String, String)
,
post(Tweet)
,
Constant Field Valuespublic static final java.lang.String TWITTER_API_URL_SERVICE_STATUSES_SHOW
Key for Twitter API URL service statuses show.
setServiceURL(String, String)
,
findByID(String)
,
Constant Field Valuespublic static final java.lang.String TWITTER_API_URL_SERVICE_STATUSES_RETWEET
Key for Twitter API URL service statuses retweet.
setServiceURL(String, String)
,
repost(Tweet)
,
Constant Field Valuespublic static final java.lang.String TWITTER_API_URL_SERVICE_DIRECT_MESSAGES_NEW
Key for Twitter API URL service direct messages new.
setServiceURL(String, String)
,
send(Tweet)
,
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_STATUSES_UPDATE
,
TWITTER_API_URL_SERVICE_STATUSES_SHOW
,
TWITTER_API_URL_SERVICE_STATUSES_RETWEET
,
TWITTER_API_URL_SERVICE_DIRECT_MESSAGES_NEW
public static TweetER getInstance(UserAccountManager uam)
Get an instance of TweetER 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 TweetER getInstance()
Get a single instance of TweetER class, which is NOT associated to any user account.
public Tweet findByID(java.lang.String id) throws LimitExceededException, java.io.IOException
Find the tweet associated to the given ID. This method does not require
to be logged in to Twitter to use it. In other words, you can use the
TweetER single instance (getInstance()
). If the given ID
does not exist, null
will be returned.
id
- Tweet's ID.
LimitExceededException
- If the limit of access is exceeded.
java.io.IOException
- If an I/O error occurs.
java.lang.SecurityException
- If the requested tweet is protected.
java.lang.IllegalArgumentException
- If the given ID is empty/null.public Tweet post(Tweet tweet) throws java.io.IOException, LimitExceededException
Post a given tweet to Twitter. The tweet's content must be up to 140
characters and must be properly logged in (UserAccountManager
).
tweet
- Tweet to be posted.
java.io.IOException
- If an I/O error occurs.
LimitExceededException
- If limit has been hit.
java.lang.SecurityException
- If it is not properly logged in.
java.lang.IllegalArgumentException
- If the given tweet is null/empty, etc.public Tweet repost(Tweet tweet) throws java.io.IOException, LimitExceededException
Repost a given tweet to Twitter.
tweet
- Tweet to be reposted.
java.io.IOException
- If an I/O error occurs.
LimitExceededException
- If limit has been hit.
java.lang.SecurityException
- If it is not properly logged in.
java.lang.IllegalArgumentException
- If the given tweet is null/empty, etc.
InvalidQueryException
- If tweet's ID is invalid.public Tweet send(Tweet dm) throws java.io.IOException, LimitExceededException
Send a given Direct Message to a given recipient. The DM's content must
be up to 140 characters, addressed to a proper user (he/she must also
follow you) and must be properly logged in (UserAccountManager
).
dm
- Direct Message to be sent.
java.io.IOException
- If an I/O error occurs.
LimitExceededException
- If limit has been hit.
InvalidQueryException
- If recipient does not exist or the sender
does not follow the recipient and vice versa.
java.lang.SecurityException
- If it is not properly logged in.
java.lang.IllegalArgumentException
- If the given DM is null/empty, etc.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |