我正在开发一个 Android 应用程序。我需要连接到我的 PHP,我正在使用 HttpPost。这是我的代码。我已经遵循了几个教程,但它不起作用。错误是 PHP 没有收到我从应用程序代码传递的参数。虽然它正确连接到 PHP。我使用 POSTman 来查找 PHP 中的错误,但它工作正常。我把我的代码放在这里:
private void httppostconnect(ArrayList<NameValuePair> parametros, String urlwebserver) {
try {
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(urlwebserver);
httppost.setEntity(new UrlEncodedFormEntity(parametros));
//ejecuto peticion enviando datos por POST
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
is = entity.getContent();
} catch(Exception e) {
Log.e("GetBuscadas", "Error in http connection "+e.toString());
}
}