Skip to content

Instantly share code, notes, and snippets.

@russellhaering
Created November 14, 2010 01:46
Show Gist options
  • Save russellhaering/675824 to your computer and use it in GitHub Desktop.
Save russellhaering/675824 to your computer and use it in GitHub Desktop.
Base API class
public class CloudkickAPI {
private static final String TAG = "CloudkickAPI";
private static String API_HOST = "api.cloudkick.com";
private static String API_VERSION = "1.0";
private final String key;
private final String secret;
private final HttpClient client;
private SharedPreferences prefs = null;
public CloudkickAPI(Context context) throws EmptyCredentialsException {
prefs = PreferenceManager.getDefaultSharedPreferences(context);
key = prefs.getString("editKey", "");
secret = prefs.getString("editSecret", "");
if (key == "" || secret == "") {
throw new EmptyCredentialsException();
}
HttpParams params = new BasicHttpParams();
HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
HttpProtocolParams.setContentCharset(params, HTTP.DEFAULT_CONTENT_CHARSET);
HttpProtocolParams.setUseExpectContinue(params, true);
SchemeRegistry registry = new SchemeRegistry();
registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
registry.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));
ClientConnectionManager connman = new ThreadSafeClientConnManager(params, registry);
client = new DefaultHttpClient(connman, params);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment