2012-09-29 47 views

回答

1
 DefaultHttpClient httpclient = new DefaultHttpClient(); 
     HttpPost httpost = new HttpPost("https://www.example.com/..."); 

     try { 
     List<NameValuePair> nvps = new ArrayList<NameValuePair>(); 
     nvps.add(new BasicNameValuePair("email", "login")); 
     nvps.add(new BasicNameValuePair("password", "pw")); 
     nvps.add(new BasicNameValuePair("autologin", "true")); 
     httpost.setEntity(new UrlEncodedFormEntity(nvps)); 

     } 
     catch (UnsupportedEncodingException e) { 
      // writing error to Log 
      e.printStackTrace(); 
     } 
     try { 
      HttpResponse response = httpclient.execute(httpost); 

      // writing response to log 
      Log.d("Http Response:", response.toString()); 

     } catch (ClientProtocolException e) { 
      // writing exception to log 
      e.printStackTrace(); 

     } catch (IOException e) { 
      // writing exception to log 
      e.printStackTrace(); 
     } 
+0

所以,如果我想使用这个我有恩放在“用户名” ctrl_LoginControl .. 。ecc? – matteo

+0

是的,NameValuePair中的项目将成为请求的参数。 – Swayam