2014-03-13 86 views

回答

0

下面是完整的代碼來調用執行HTTP(POST REQ)

  try { 
      ArrayList<NameValuePair> nvp = new ArrayList<NameValuePair>(3); 

      nvp.add(new BasicNameValuePair("username", et_email.getText().toString())); 
      nvp.add(new BasicNameValuePair("password", et_password.getText().toString())); 
      HttpClient httpclient = new DefaultHttpClient(); 
      HttpPost httppost = new HttpPost("url to be called"); 
      httppost.setEntity(new UrlEncodedFormEntity(nvp)); 
      ResponseHandler<String> responseHandler = new BasicResponseHandler(); 
      final String responseBody = httpclient.execute(httppost, responseHandler); 
      Log.i("response", responseBody); 



     } catch (Exception e) { 
      Log.i("error1", "" + e.toString()); 
     } 
+0

唐'用NVP(名稱值對),如果你不發送任何參數。 –

+0

但它不是HTTPS :( – ioann