0
PostMethod postMethod = new PostMethod("http://abc.com/a.php");
postMethod.setRequestEntity(new InputStreamRequestEntity(new ByteArrayInputStream(someString.getBytes())));
HttpClient httpClient = initMultithreadedHttpClient(ConnectionTimeout,
SocketTimeout, MaxRetry);
httpClient.executeMethod(postMethod);
這是我從Java客戶端向PHP服務器發送數據的方式。
如何在PHP中讀取它?在PHP中讀取由Java發送的HttpRequest
我試圖捕捉到的數據是這樣的:
<?php
$fp = fopen("/opt/lampp/htdocs/input.txt","w");
ob_start();
print_r($_REQUEST);
print_r($_SERVER);
print_r(http_get_request_body());
fprintf($fp,"%s",ob_get_contents());
ob_end_clean();
fclose($fp);
?>
但它並沒有真正打印請求數據。