开发者

JSONRPC on Android does not POST

开发者 https://www.devze.com 2023-02-27 02:17 出处:网络
I have the following code: JSONObject jsonRequest = new JSONObject(); jsonRequest.put(\"id\", 1); jsonRequest.put(\"method\", \"mymethod\");

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');
0

精彩评论

暂无评论...
验证码 换一张
取 消