twitter4j
Class TwitterOAuthSupportBase

java.lang.Object
  extended by twitter4j.TwitterBase
      extended by twitter4j.TwitterOAuthSupportBase
All Implemented Interfaces:
java.io.Serializable, OAuthSupport, twitter4j.internal.http.HttpResponseCode, twitter4j.internal.http.HttpResponseListener
Direct Known Subclasses:
AsyncTwitter, Twitter

abstract class TwitterOAuthSupportBase
extends TwitterBase
implements twitter4j.internal.http.HttpResponseCode, twitter4j.internal.http.HttpResponseListener, OAuthSupport, java.io.Serializable


Field Summary
protected  twitter4j.internal.http.HttpClientWrapper http
           
protected  RateLimitStatusListener rateLimitStatusListener
           
private static long serialVersionUID
           
 
Fields inherited from class twitter4j.TwitterBase
auth, conf
 
Fields inherited from interface twitter4j.internal.http.HttpResponseCode
BAD_GATEWAY, BAD_REQUEST, ENHANCE_YOUR_CLAIM, FORBIDDEN, INTERNAL_SERVER_ERROR, NOT_ACCEPTABLE, NOT_FOUND, NOT_MODIFIED, OK, SERVICE_UNAVAILABLE, UNAUTHORIZED
 
Constructor Summary
TwitterOAuthSupportBase(Configuration conf)
           
TwitterOAuthSupportBase(Configuration conf, Authorization auth)
           
TwitterOAuthSupportBase(Configuration conf, java.lang.String screenName, java.lang.String password)
           
 
Method Summary
 boolean equals(java.lang.Object o)
           
abstract  AccessToken getOAuthAccessToken()
          Returns an access token associated with this instance.
If no access token is associated with this instance, this will retrieve a new access token.
abstract  AccessToken getOAuthAccessToken(RequestToken requestToken)
          Retrieves an access token associated with the supplied request token and sets userId.
abstract  AccessToken getOAuthAccessToken(RequestToken requestToken, java.lang.String oauthVerifier)
          Retrieves an access token associated with the supplied request token and sets userId.
abstract  AccessToken getOAuthAccessToken(java.lang.String oauthVerifier)
          Retrieves an access token.
abstract  AccessToken getOAuthAccessToken(java.lang.String token, java.lang.String tokenSecret)
           
abstract  AccessToken getOAuthAccessToken(java.lang.String token, java.lang.String tokenSecret, java.lang.String pin)
          Deprecated. Use getOAuthAccessToken(twitter4j.http.RequestToken, String) instead
abstract  RequestToken getOAuthRequestToken()
          Retrieves a request token
abstract  RequestToken getOAuthRequestToken(java.lang.String callbackUrl)
          Retrieves a request token
 int hashCode()
           
 void httpResponseReceived(twitter4j.internal.http.HttpResponseEvent event)
           
private  void init()
           
 boolean isOAuthEnabled()
          tests if the instance is authenticated by Basic
private  void readObject(java.io.ObjectInputStream stream)
           
abstract  void setOAuthAccessToken(AccessToken accessToken)
          Sets the access token
abstract  void setOAuthAccessToken(java.lang.String token, java.lang.String tokenSecret)
          Deprecated. Use TwitterFactory.getInstance(twitter4j.http.Authorization) instead
abstract  void setOAuthConsumer(java.lang.String consumerKey, java.lang.String consumerSecret)
          Deprecated. Use TwitterFactory.getInstance(twitter4j.conf.Configuration, twitter4j.http.Authorization) instead
 void setRateLimitStatusListener(RateLimitStatusListener listener)
          Registers a RateLimitStatusListener for account associated rate limits
private  void writeObject(java.io.ObjectOutputStream out)
           
 
Methods inherited from class twitter4j.TwitterBase
ensureAuthorizationEnabled, ensureBasicEnabled, getAuthorization, isBasicAuthEnabled, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

http

protected transient twitter4j.internal.http.HttpClientWrapper http

rateLimitStatusListener

protected RateLimitStatusListener rateLimitStatusListener

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values
Constructor Detail

TwitterOAuthSupportBase

TwitterOAuthSupportBase(Configuration conf)

TwitterOAuthSupportBase

TwitterOAuthSupportBase(Configuration conf,
                        java.lang.String screenName,
                        java.lang.String password)

TwitterOAuthSupportBase

TwitterOAuthSupportBase(Configuration conf,
                        Authorization auth)
Method Detail

init

private void init()

writeObject

private void writeObject(java.io.ObjectOutputStream out)
                  throws java.io.IOException
Throws:
java.io.IOException

readObject

private void readObject(java.io.ObjectInputStream stream)
                 throws java.io.IOException,
                        java.lang.ClassNotFoundException
Throws:
java.io.IOException
java.lang.ClassNotFoundException

setOAuthConsumer

public abstract void setOAuthConsumer(java.lang.String consumerKey,
                                      java.lang.String consumerSecret)
Deprecated. Use TwitterFactory.getInstance(twitter4j.conf.Configuration, twitter4j.http.Authorization) instead

sets the OAuth consumer key and consumer secret

Parameters:
consumerKey - OAuth consumer key
consumerSecret - OAuth consumer secret
Throws:
java.lang.IllegalStateException - when OAuth consumer has already been set, or the instance is using basic authorization
Since:
Twitter 2.0.0

getOAuthRequestToken

public abstract RequestToken getOAuthRequestToken()
                                           throws TwitterException
Description copied from interface: OAuthSupport
Retrieves a request token

Specified by:
getOAuthRequestToken in interface OAuthSupport
Returns:
generated request token.
Throws:
TwitterException - when Twitter service or network is unavailable
See Also:
Twitter API Wiki - OAuth FAQ, OAuth Core 1.0a - 6.1. Obtaining an Unauthorized Request Token

getOAuthRequestToken

public abstract RequestToken getOAuthRequestToken(java.lang.String callbackUrl)
                                           throws TwitterException
Description copied from interface: OAuthSupport
Retrieves a request token

Specified by:
getOAuthRequestToken in interface OAuthSupport
Parameters:
callbackUrl - callback URL
Returns:
generated request token
Throws:
TwitterException - when Twitter service or network is unavailable
See Also:
Twitter API Wiki - OAuth FAQ, OAuth Core 1.0a - 6.1. Obtaining an Unauthorized Request Token

getOAuthAccessToken

public abstract AccessToken getOAuthAccessToken()
                                         throws TwitterException
Description copied from interface: OAuthSupport
Returns an access token associated with this instance.
If no access token is associated with this instance, this will retrieve a new access token.

Specified by:
getOAuthAccessToken in interface OAuthSupport
Returns:
access token
Throws:
TwitterException - when Twitter service or network is unavailable, or the user has not authorized
See Also:
Twitter API Wiki - How long does an access token last?, OAuth Core 1.0a - 6.2. Obtaining User Authorization

getOAuthAccessToken

public abstract AccessToken getOAuthAccessToken(java.lang.String oauthVerifier)
                                         throws TwitterException
Description copied from interface: OAuthSupport
Retrieves an access token.

Specified by:
getOAuthAccessToken in interface OAuthSupport
Parameters:
oauthVerifier - OAuth verifier. AKA pin.
Returns:
access token
Throws:
TwitterException - when Twitter service or network is unavailable, or the user has not authorized
See Also:
Twitter API Wiki - How long does an access token last?, OAuth Core 1.0a - 6.2. Obtaining User Authorization

getOAuthAccessToken

public abstract AccessToken getOAuthAccessToken(RequestToken requestToken)
                                         throws TwitterException
Description copied from interface: OAuthSupport
Retrieves an access token associated with the supplied request token and sets userId.

Specified by:
getOAuthAccessToken in interface OAuthSupport
Parameters:
requestToken - the request token
Returns:
access token associated with the supplied request token.
Throws:
TwitterException - when Twitter service or network is unavailable, or the user has not authorized
See Also:
Twitter API Wiki - How long does an access token last?, OAuth Core 1.0a - 6.2. Obtaining User Authorization

getOAuthAccessToken

public abstract AccessToken getOAuthAccessToken(RequestToken requestToken,
                                                java.lang.String oauthVerifier)
                                         throws TwitterException
Description copied from interface: OAuthSupport
Retrieves an access token associated with the supplied request token and sets userId.

Specified by:
getOAuthAccessToken in interface OAuthSupport
Parameters:
requestToken - the request token
oauthVerifier - OAuth verifier. AKA pin.
Returns:
access token associated with the supplied request token.
Throws:
TwitterException - when Twitter service or network is unavailable, or the user has not authorized
See Also:
OAuth Core 1.0a - 6.2. Obtaining User Authorization

setOAuthAccessToken

public abstract void setOAuthAccessToken(AccessToken accessToken)
Description copied from interface: OAuthSupport
Sets the access token

Specified by:
setOAuthAccessToken in interface OAuthSupport
Parameters:
accessToken - accessToken

getOAuthAccessToken

public abstract AccessToken getOAuthAccessToken(java.lang.String token,
                                                java.lang.String tokenSecret)
                                         throws TwitterException
Throws:
TwitterException

getOAuthAccessToken

public abstract AccessToken getOAuthAccessToken(java.lang.String token,
                                                java.lang.String tokenSecret,
                                                java.lang.String pin)
                                         throws TwitterException
Deprecated. Use getOAuthAccessToken(twitter4j.http.RequestToken, String) instead

Retrieves an access token associated with the supplied request token.

Parameters:
token - request token
tokenSecret - request token secret
pin - pin
Returns:
access token associated with the supplied request token.
Throws:
TwitterException - when Twitter service or network is unavailable, or the user has not authorized
Since:
Twitter 2.0.8
See Also:
Twitter API Wiki - How long does an access token last?, OAuth Core 1.0a - 6.2. Obtaining User Authorization

setOAuthAccessToken

public abstract void setOAuthAccessToken(java.lang.String token,
                                         java.lang.String tokenSecret)
Deprecated. Use TwitterFactory.getInstance(twitter4j.http.Authorization) instead

Sets the access token

Parameters:
token - access token
tokenSecret - access token secret
Throws:
java.lang.IllegalStateException - when AccessToken has already been retrieved or set
Since:
Twitter 2.0.0

isOAuthEnabled

public boolean isOAuthEnabled()
tests if the instance is authenticated by Basic

Returns:
returns true if the instance is authenticated by Basic

setRateLimitStatusListener

public void setRateLimitStatusListener(RateLimitStatusListener listener)
Registers a RateLimitStatusListener for account associated rate limits

Parameters:
listener - the listener to be added
Since:
Twitter4J 2.1.0
See Also:
Twitter API Wiki / Twitter REST API Method: account rate_limit_status

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class TwitterBase

hashCode

public int hashCode()
Overrides:
hashCode in class TwitterBase

httpResponseReceived

public void httpResponseReceived(twitter4j.internal.http.HttpResponseEvent event)
Specified by:
httpResponseReceived in interface twitter4j.internal.http.HttpResponseListener