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);
This is how I am sending data from Java client to PHP server.
How do I read it in PHP?
I tried to capture the data like this:
<?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);
?>
But it didn’t really print the request data.
You can read raw POST data in PHP with…
I prefer this method over the
$HTTP_RAW_POST_DATAglobal.