Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.twitterapime.rest
Class TweetER

    java.lang.Object
      com.twitterapime.rest.TweetER

    public final class TweetER

extends java.lang.Object

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");

Since:
  1.1
Version:
  1.3
Author:
  Ernandes Mourao Junior (ernandes@gmail.com)
See Also:
  `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

### TWITTER_API_URL_SERVICE_STATUSES_UPDATE

    public static final java.lang.String TWITTER_API_URL_SERVICE_STATUSES_UPDATE

  Key for Twitter API URL service statuses update.

  See Also:
    `setServiceURL(String, String)`, `post(Tweet)`, Constant Field Values

### TWITTER_API_URL_SERVICE_STATUSES_SHOW

    public static final java.lang.String TWITTER_API_URL_SERVICE_STATUSES_SHOW

  Key for Twitter API URL service statuses show.

  See Also:
    `setServiceURL(String, String)`, `findByID(String)`, Constant Field Values

### TWITTER_API_URL_SERVICE_STATUSES_RETWEET

    public static final java.lang.String TWITTER_API_URL_SERVICE_STATUSES_RETWEET

  Key for Twitter API URL service statuses retweet.

  See Also:
    `setServiceURL(String, String)`, `repost(Tweet)`, Constant Field Values

### TWITTER_API_URL_SERVICE_DIRECT_MESSAGES_NEW

    public static final java.lang.String TWITTER_API_URL_SERVICE_DIRECT_MESSAGES_NEW

  Key for Twitter API URL service direct messages new.

  See Also:
    `setServiceURL(String, String)`, `send(Tweet)`, Constant Field Values

Method Detail

### setServiceURL

    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.

  Parameters:
    `serviceKey` - Service key.
    `url` - New URL.
  See Also:
    `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`

### getInstance

    public static TweetER getInstance(UserAccountManager uam)

  Get an instance of TweetER class and associate it to a given user account.

  Parameters:
    `uam` - User account manager.
  Returns:
    TweetER instance.
  Throws:
    `java.lang.IllegalArgumentException` - If UserAccountManager is null.
    `java.lang.SecurityException` - If UserAccountManager is not verified.

### getInstance

    public static TweetER getInstance()

  Get a single instance of TweetER class, which is NOT associated to any user account.

  Returns:
    TweetER single instance.

### findByID

    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.

  Parameters:
    `id` - Tweet's ID.
  Returns:
    Tweet.
  Throws:
    `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.

### post

    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`).

  Parameters:
    `tweet` - Tweet to be posted.
  Returns:
    Tweet post with some additional data.
  Throws:
    `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.

### repost

    public Tweet repost(Tweet tweet)
                 throws java.io.IOException,
                        LimitExceededException

  Repost a given tweet to Twitter.

  Parameters:
    `tweet` - Tweet to be reposted.
  Returns:
    Tweet reposted.
  Throws:
    `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.

### send

    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`).

  Parameters:
    `dm` - Direct Message to be sent.
  Returns:
    Sent Direct Message.
  Throws:
    `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.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2010 Twitter API ME Team. All Rights Reserved.