Posts

Showing posts from May, 2014

Executing a HTTP POST Request with HttpClient

public void postData() {     // Create a new HttpClient and Post Header     HttpClient httpclient = new DefaultHttpClient();     HttpPost httppost = new HttpPost("http://www.yoursite.com/script.php");     try {         // Add your data         List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);         nameValuePairs.add(new BasicNameValuePair(“username”, "12345"));         nameValuePairs.add(new BasicNameValuePair(“password”, “ghgjhj”));         httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));         // Execute HTTP Post Request         HttpResponse response = httpclient.execute(httppost);             } catch (ClientProtocolException e) {         // TODO Auto-generated catch block     } c...