twitter4j.http
Class HttpClient

java.lang.Object
  extended by twitter4j.http.HttpClient
All Implemented Interfaces:
java.io.Serializable

public class HttpClient
extends java.lang.Object
implements java.io.Serializable

A utility class to handle HTTP request/response.

Author:
Yusuke Yamamoto - yusuke at mac.com
See Also:
Serialized Form

Constructor Summary
HttpClient()
           
HttpClient(java.lang.String userId, java.lang.String password)
           
 
Method Summary
static java.lang.String encodeParameters(PostParameter[] postParams)
           
 boolean equals(java.lang.Object o)
           
 Response get(java.lang.String url)
           
 Response get(java.lang.String url, boolean authenticated)
           
 java.lang.String getAccessTokenURL()
           
 java.lang.String getAuthenticationRL()
          since Twitter4J 2.0.10
 java.lang.String getAuthorizationURL()
           
 int getConnectionTimeout()
           
 AccessToken getOAuthAccessToken(RequestToken token)
           
 AccessToken getOAuthAccessToken(RequestToken token, java.lang.String pin)
           
 AccessToken getOAuthAccessToken(java.lang.String token, java.lang.String tokenSecret)
           
 AccessToken getOAuthAccessToken(java.lang.String token, java.lang.String tokenSecret, java.lang.String oauth_verifier)
           
 RequestToken getOAuthRequestToken()
           
 RequestToken getOauthRequestToken(java.lang.String callback_url)
           
 java.lang.String getPassword()
           
 java.lang.String getProxyAuthPassword()
           
 java.lang.String getProxyAuthUser()
           
 java.lang.String getProxyHost()
           
 int getProxyPort()
           
 int getReadTimeout()
           
 java.lang.String getRequestHeader(java.lang.String name)
           
 java.lang.String getRequestTokenURL()
           
 java.lang.String getUserAgent()
           
 java.lang.String getUserId()
           
 int hashCode()
           
protected  Response httpRequest(java.lang.String url, PostParameter[] postParams, boolean authenticated)
           
 boolean isAuthenticationEnabled()
           
 Response post(java.lang.String url)
           
 Response post(java.lang.String url, boolean authenticated)
           
 Response post(java.lang.String url, PostParameter[] PostParameters)
           
 Response post(java.lang.String url, PostParameter[] postParameters, boolean authenticated)
           
 void setAccessTokenURL(java.lang.String accessTokenURL)
           
 void setAuthorizationURL(java.lang.String authorizationURL)
           
 void setConnectionTimeout(int connectionTimeout)
          Sets a specified timeout value, in milliseconds, to be used when opening a communications link to the resource referenced by this URLConnection.
 void setOAuthAccessToken(AccessToken token)
          Sets the authorized access token
 void setOAuthConsumer(java.lang.String consumerKey, java.lang.String consumerSecret)
          Sets the consumer key and consumer secret.
System property -Dtwitter4j.oauth.consumerKey and -Dhttp.oauth.consumerSecret override this attribute.
 void setPassword(java.lang.String password)
           
 void setProxyAuthPassword(java.lang.String proxyAuthPassword)
          Sets proxy authentication password.
 void setProxyAuthUser(java.lang.String proxyAuthUser)
          Sets proxy authentication user.
 void setProxyHost(java.lang.String proxyHost)
          Sets proxy host.
 void setProxyPort(int proxyPort)
          Sets proxy port.
 void setReadTimeout(int readTimeout)
          Sets the read timeout to a specified timeout, in milliseconds.
 void setRequestHeader(java.lang.String name, java.lang.String value)
           
 void setRequestTokenURL(java.lang.String requestTokenURL)
           
 void setRetryCount(int retryCount)
           
 void setRetryIntervalSecs(int retryIntervalSecs)
           
 void setUserAgent(java.lang.String ua)
           
 void setUserId(java.lang.String userId)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpClient

public HttpClient(java.lang.String userId,
                  java.lang.String password)

HttpClient

public HttpClient()
Method Detail

setUserId

public void setUserId(java.lang.String userId)

setPassword

public void setPassword(java.lang.String password)

getUserId

public java.lang.String getUserId()

getPassword

public java.lang.String getPassword()

isAuthenticationEnabled

public boolean isAuthenticationEnabled()

setOAuthConsumer

public void setOAuthConsumer(java.lang.String consumerKey,
                             java.lang.String consumerSecret)
Sets the consumer key and consumer secret.
System property -Dtwitter4j.oauth.consumerKey and -Dhttp.oauth.consumerSecret override this attribute.

Parameters:
consumerKey - Consumer Key
consumerSecret - Consumer Secret
Since:
Twitter4J 2.0.0
See Also:
Applications Using Twitter

getOAuthRequestToken

public RequestToken getOAuthRequestToken()
                                  throws TwitterException
Returns:
request token
Throws:
TwitterException - tw
Since:
Twitter4J 2.0.0

getOauthRequestToken

public RequestToken getOauthRequestToken(java.lang.String callback_url)
                                  throws TwitterException
Parameters:
callback_url - callback url
Returns:
request token
Throws:
TwitterException - tw
Since:
Twitter4J 2.0.9

getOAuthAccessToken

public AccessToken getOAuthAccessToken(RequestToken token)
                                throws TwitterException
Parameters:
token - request token
Returns:
access token
Throws:
TwitterException
Since:
Twitter4J 2.0.0

getOAuthAccessToken

public AccessToken getOAuthAccessToken(RequestToken token,
                                       java.lang.String pin)
                                throws TwitterException
Parameters:
token - request token
Returns:
access token
Throws:
TwitterException
Since:
Twitter4J 2.0.8

getOAuthAccessToken

public AccessToken getOAuthAccessToken(java.lang.String token,
                                       java.lang.String tokenSecret)
                                throws TwitterException
Parameters:
token - request token
tokenSecret - request token secret
Returns:
access token
Throws:
TwitterException
Since:
Twitter4J 2.0.1

getOAuthAccessToken

public AccessToken getOAuthAccessToken(java.lang.String token,
                                       java.lang.String tokenSecret,
                                       java.lang.String oauth_verifier)
                                throws TwitterException
Parameters:
token - request token
tokenSecret - request token secret
oauth_verifier - oauth_verifier or pin
Returns:
access token
Throws:
TwitterException
Since:
Twitter4J 2.0.8

setOAuthAccessToken

public void setOAuthAccessToken(AccessToken token)
Sets the authorized access token

Parameters:
token - authorized access token
Since:
Twitter4J 2.0.0

setRequestTokenURL

public void setRequestTokenURL(java.lang.String requestTokenURL)

getRequestTokenURL

public java.lang.String getRequestTokenURL()

setAuthorizationURL

public void setAuthorizationURL(java.lang.String authorizationURL)

getAuthorizationURL

public java.lang.String getAuthorizationURL()

getAuthenticationRL

public java.lang.String getAuthenticationRL()
since Twitter4J 2.0.10


setAccessTokenURL

public void setAccessTokenURL(java.lang.String accessTokenURL)

getAccessTokenURL

public java.lang.String getAccessTokenURL()

getProxyHost

public java.lang.String getProxyHost()

setProxyHost

public void setProxyHost(java.lang.String proxyHost)
Sets proxy host. System property -Dtwitter4j.http.proxyHost or http.proxyHost overrides this attribute.

Parameters:
proxyHost -

getProxyPort

public int getProxyPort()

setProxyPort

public void setProxyPort(int proxyPort)
Sets proxy port. System property -Dtwitter4j.http.proxyPort or -Dhttp.proxyPort overrides this attribute.

Parameters:
proxyPort -

getProxyAuthUser

public java.lang.String getProxyAuthUser()

setProxyAuthUser

public void setProxyAuthUser(java.lang.String proxyAuthUser)
Sets proxy authentication user. System property -Dtwitter4j.http.proxyUser overrides this attribute.

Parameters:
proxyAuthUser -

getProxyAuthPassword

public java.lang.String getProxyAuthPassword()

setProxyAuthPassword

public void setProxyAuthPassword(java.lang.String proxyAuthPassword)
Sets proxy authentication password. System property -Dtwitter4j.http.proxyPassword overrides this attribute.

Parameters:
proxyAuthPassword -

getConnectionTimeout

public int getConnectionTimeout()

setConnectionTimeout

public void setConnectionTimeout(int connectionTimeout)
Sets a specified timeout value, in milliseconds, to be used when opening a communications link to the resource referenced by this URLConnection. System property -Dtwitter4j.http.connectionTimeout overrides this attribute.

Parameters:
connectionTimeout - - an int that specifies the connect timeout value in milliseconds

getReadTimeout

public int getReadTimeout()

setReadTimeout

public void setReadTimeout(int readTimeout)
Sets the read timeout to a specified timeout, in milliseconds. System property -Dtwitter4j.http.readTimeout overrides this attribute.

Parameters:
readTimeout - - an int that specifies the timeout value to be used in milliseconds

setRetryCount

public void setRetryCount(int retryCount)

setUserAgent

public void setUserAgent(java.lang.String ua)

getUserAgent

public java.lang.String getUserAgent()

setRetryIntervalSecs

public void setRetryIntervalSecs(int retryIntervalSecs)

post

public Response post(java.lang.String url,
                     PostParameter[] postParameters,
                     boolean authenticated)
              throws TwitterException
Throws:
TwitterException

post

public Response post(java.lang.String url,
                     boolean authenticated)
              throws TwitterException
Throws:
TwitterException

post

public Response post(java.lang.String url,
                     PostParameter[] PostParameters)
              throws TwitterException
Throws:
TwitterException

post

public Response post(java.lang.String url)
              throws TwitterException
Throws:
TwitterException

get

public Response get(java.lang.String url,
                    boolean authenticated)
             throws TwitterException
Throws:
TwitterException

get

public Response get(java.lang.String url)
             throws TwitterException
Throws:
TwitterException

httpRequest

protected Response httpRequest(java.lang.String url,
                               PostParameter[] postParams,
                               boolean authenticated)
                        throws TwitterException
Throws:
TwitterException

encodeParameters

public static java.lang.String encodeParameters(PostParameter[] postParams)

setRequestHeader

public void setRequestHeader(java.lang.String name,
                             java.lang.String value)

getRequestHeader

public java.lang.String getRequestHeader(java.lang.String name)

equals

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

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object


Copyright © 2009. All Rights Reserved.