Android HttpPost 返回 <!DOCTYPE HTML PUBLIC "//IETF//DTD HTML 2.0//EN" > 作为响应



HttpPost 返回此响应<!DOCTYPE HTML PUBLIC "//IETF//DTD HTML 2.0//EN"> 我花时间试图找出原因,但我不知道为什么。请有人帮我。将数据发送到托管在Byethost的PHP站点。有趣的是它在本地服务器上工作正常。可能是什么问题?

在安卓中

HttpPost request = new HttpPost(url);
request.setEntity(new ByteArrayEntity(json.toString().getBytes("UTF8"))); 
request.setHeader("Content-type: application/json", json.toString());    
HttpResponse response = client.execute(request);

在 PHP 中

header('Content-type: application/json');
$json = file_get_contents('php://input');
$obj = json_decode($json);

相关内容

最新更新