从android的php服务器发送请求并获取响应

从android的php服务器发送请求并获取响应,php,android,json,url,Php,Android,Json,Url,我正试图将一个http请求以查询字符串(例如:url?值)的格式发送到php服务器,并在我的android设备上获得响应。 但是HttpPost-HttpPost=newhttppost(URL)正在引发异常 注意:我只能以这种格式发送,否则请告知php代码服务器程序员如何读取请求,如: HttpPost httppost = new HttpPost(URL); JSONObject json = new JSONObject(); try { // JSON data: js

我正试图将一个http请求以查询字符串(例如:url?值)的格式发送到php服务器,并在我的android设备上获得响应。 但是
HttpPost-HttpPost=newhttppost(URL)正在引发异常

注意:我只能以这种格式发送,否则请告知php代码服务器程序员如何读取请求,如:

HttpPost httppost = new HttpPost(URL);
JSONObject json = new JSONObject();
try {
    // JSON data:
    json.put("PN", "Products");
    json.put("position", "5th");

    JSONArray postjson=new JSONArray();
    postjson.put(json);

    // Post the data:

    httppost.setHeader("json",json.toString());
    HttpParams ht=httppost.getParams().setParameter("jsonpost",postjson);
    String s=ht.toString();
    // Execute HTTP Post Request

    HttpResponse response = httpclient.execute(httppost);

尝试在此处替换json.tostring():


将其替换为“application/json”

它会引发什么异常?它会引发异常invokespecial java.lang.RuntimeException(java.lang.String)还有一个错误/AndroidRuntime(8647):位于java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273),如果您可以将整个堆栈跟踪添加到您的问题中,这会很有帮助。
httppost.setHeader("json",json.toString());