winterwell.jtwitter
Interface Twitter.IHttpClient

All Known Implementing Classes:
URLConnectionHttpClient
Enclosing class:
Twitter

public static interface Twitter.IHttpClient

Interface for an http client - e.g. allows for OAuth to be used instead. The default version is URLConnectionHttpClient.

If creating your own version, please provide support for throwing the right subclass of TwitterException - see URLConnectionHttpClient.processError(java.net.HttpURLConnection) for example code.

Author:
Daniel Winterstein

Method Summary
 boolean canAuthenticate()
          Whether this client can authenticate to the server.
 java.lang.String getPage(java.lang.String uri, java.util.Map<java.lang.String,java.lang.String> vars, boolean authenticate)
          Send an HTTP GET request and return the response body.
 java.lang.String post(java.lang.String uri, java.util.Map<java.lang.String,java.lang.String> vars, boolean authenticate)
          Send an HTTP POST request and return the response body.
 

Method Detail

canAuthenticate

boolean canAuthenticate()
Whether this client can authenticate to the server.


getPage

java.lang.String getPage(java.lang.String uri,
                         java.util.Map<java.lang.String,java.lang.String> vars,
                         boolean authenticate)
                         throws TwitterException
Send an HTTP GET request and return the response body. Note that this will change all line breaks into system line breaks!

Parameters:
uri - The uri to fetch
vars - get arguments to add to the uri
authenticate - If true, use authentication. The authentication method used depends on the implementation (basic-auth, OAuth). It is an error to use true if no authentication details have been set.
Throws:
TwitterException - for a variety of reasons
TwitterException.E404 - for resource-does-not-exist errors

post

java.lang.String post(java.lang.String uri,
                      java.util.Map<java.lang.String,java.lang.String> vars,
                      boolean authenticate)
                      throws TwitterException
Send an HTTP POST request and return the response body.

Parameters:
uri - The uri to post to.
vars - The form variables to send. These are URL encoded before sending.
authenticate - If true, send user authentication
Returns:
The response from the server.
Throws:
TwitterException - for a variety of reasons
TwitterException.E404 - for resource-does-not-exist errors


Copyright © 2014 gvSIG Association. All Rights Reserved.