Starting arguments
in
Contributed Library Questions
•
1 year ago
This is the first time I am trying to make something like this, so I am pretty much just on the copy/paste/modify stage. ;)
- import org.apache.http.HttpEntity;
- import org.apache.http.HttpResponse;
- import org.apache.http.client.methods.HttpPost;
- import org.apache.http.impl.client.DefaultHttpClient;
- void setup()
- {
- String prop = System.getProperty("key");
- String url = "http://url.com&name=" + prop;
- try
- {
- DefaultHttpClient httpClient = new DefaultHttpClient();
- HttpPost httpPost = new HttpPost( url );
- HttpParams postParams = new BasicHttpParams();
- //postParams.setParameter( "your_name", "John Smith" );
- //postParams.setParameter( "fruit", "Apricot" ); // Configure the form parameters
- //httpPost.setParams( postParams );
- println( "executing request: " + httpPost.getRequestLine() );
- HttpResponse response = httpClient.execute( httpPost );
- HttpEntity entity = response.getEntity();
- println("----------------------------------------");
- println( response.getStatusLine() );
- println("----------------------------------------");
- if ( entity != null ) entity.writeTo( System.out );
- if ( entity != null ) entity.consumeContent();
- httpClient.getConnectionManager().shutdown();
- }
- catch( Exception e )
- {
- e.printStackTrace();
- }
- exit();
- }
1