2014-03-13 42 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