-
Notifications
You must be signed in to change notification settings - Fork 5
MapleHttpClient
elihart edited this page Mar 21, 2013
·
6 revisions
This class provides easy methods for get and post requests to our main website. It is built on the loopj library
This class can only be used to access our website. It accepts relative urls that are then combined with the base url of the website to get the absolute destination. For example, To reach http://maplesyrup.com/companies simply pass in "companies".
/** Does an asynchronous get request and returns the result as a string
* in the responseHandler call back function.
* @param url The Get destination. This is relative to our website's homename. To get http://maplesyrup.com/companies simply pass in "companies"
* @param params Any parameters you wish to include in the get request. Pass null if you have none
* @param responseHandler This handler acts as a callback function to provide the results of the get request on success or failure
*/
public static void get(String url, RequestParams params, AsyncHttpResponseHandler responseHandler) {
client.get(getAbsoluteUrl(url), params, responseHandler);
}
/** Does an asynchronous post request
* @param url The post destination. This is relative to our website's homename. To reach http://maplesyrup.com/companies simply pass in "companies"
* @param params Any parameters you wish to include in the post request. Pass null if you have none
* @param responseHandler This handler acts as a callback function to provide the results of the post request on success or failure
*/
public static void post(String url, RequestParams params, AsyncHttpResponseHandler responseHandler) {
client.post(getAbsoluteUrl(url), params, responseHandler);
}