启动一个可以通过php连接到sql server数据库的android应用程序。问题是我不知道如何将参数从android传递给PHP。我已经搜索了关于这个东西的教程,并且有很多,但所有这些都使用已经弃用的HttpClient,HttpPost和NameValuePairs(?)并且不能再使用了。 someonoe可以告诉我如何将这样的参数传递给PHP吗?
List<NameValuePair> nameValuePairList = new ArrayList<NameValuePair>();
nameValuePairList.add(new BasicNameValuePair("name", name));
nameValuePairList.add(new BasicNameValuePair("email", email));
nameValuePairList.add(new BasicNameValuePair("phone", phone));
try{
HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url);
httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairList));
HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
is = httpEntity.getContent();
etName.setText("");
etEmail.setText("");
etPhone.setText("");
Toast.makeText(getApplicationContext(), successMessage, Toast.LENGTH_SHORT).show();
is.close();
}catch(IOException e){
Toast.makeText(getApplicationContext(), exceptionMessage, Toast.LENGTH_SHORT).show();
}
感谢您的帮助