Created
April 6, 2011 15:45
-
-
Save solarsailer/905886 to your computer and use it in GitHub Desktop.
HttpRequest & Client
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private HttpClient client; | |
public HttpModule() { | |
client = new DefaultHttpClient(); | |
} | |
public void executePost() { | |
HttpPost post = new HttpPost(APIConfiguration.getURL(Protocol.HTTPS, "user")); | |
Console.log(post.getURI()); | |
try { | |
List<NameValuePair> data = new ArrayList<NameValuePair>(); | |
data.add(new BasicNameValuePair("version", APIConfiguration.API_VERSION)); | |
data.add(new BasicNameValuePair("mail", "bidon@truc.com")); | |
post.setEntity(new UrlEncodedFormEntity(data)); | |
HttpResponse response = client.execute(post); | |
Console.log(new BasicResponseHandler().handleResponse(response)); | |
} catch (ClientProtocolException e) { | |
Console.err(e); | |
} catch (IOException e) { | |
Console.err(e); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment