I have the following code:
JSONObject jsonRequest = new JSONObject();
jsonRequest.put("id", 1);
jsonRequest.put("method", "mymethod");
entity = new JSONEntity(jsonReq开发者_Python百科uest);
HttpPost request = new HttpPost("http://192.168.1.103/foo/bar.php");
request.setEntity(entity);
HttpResponse response = httpClient.execute(request);
Irrelevant code removed
It posts to a .php page. On the .php page I call var_dump
to check the content of both $_POST and $_GET. Both are empty.
Any idea?
Solved it. Obtain the data in php:
$input = file_get_contents('php://input');
精彩评论