0
在我的應用程序中,我想提出安全的HTTP請求(GET,POST),有人可以給我一個簡單的例子嗎?如何在Android中執行安全的HTTP(HTTPS)GET和POST請求?
在我的應用程序中,我想提出安全的HTTP請求(GET,POST),有人可以給我一個簡單的例子嗎?如何在Android中執行安全的HTTP(HTTPS)GET和POST請求?
下面是完整的代碼來調用執行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());
}
唐'用NVP(名稱值對),如果你不發送任何參數。 –
但它不是HTTPS :( – ioann