我的应用尝试发送这样的POST数据:
HttpClient httpclient = new DefaultHttpClient();
HttpResponse response;
HttpPost httppost = new HttpPost("http://localhost/mydir/");
try {
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("sender_app", "My app"));
nameValuePairs.add(new BasicNameValuePair("someString", "My string"));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
response = httpclient.execute(httppost);
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
} catch (IOException e) {
// TODO Auto-generated catch block
}
脚本记录此请求以进行测试,如下所示:
ob_start();
var_dump($_REQUEST);
$request_dump = "_REQUEST: ".ob_get_clean();
file_put_contents("requests.log",$request_dump, FILE_APPEND | LOCK_EX);
该应用成功发出请求并将其记录,但$_REQUEST
超全局始终为空,并且未设置sender_app
和someString
个帖子变量。
$_SERVER[HTTP_USER_AGENT]
报告为Apache-HttpClient/UNAVAILABLE (java 1.4)
,因此至少会发送_REQUEST: array(0) {
}
。
日志如下所示:
{{1}}
可能是什么问题?