我正在尝试在android中发送POST请求。但我得$ _REQUEST为空。
这是我的代码:
try {
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().permitNetwork().build());
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("firstName", firstName));
nameValuePairs.add(new BasicNameValuePair("lastName", lastName));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
// Execute HTTP Post Request
HttpResponse response = httpclient.execute(httppost);
} catch (Exception e) {
e.printStackTrace();
}
有什么建议吗?
也许我不知道如何获取参数。
在php脚本中,我有这段代码:
error_log(var_export($_REQUEST, true) . "\n", 3, "/Users/christianrusso/Desktop/crusso.log");
请求为空。