Note that there are some explanatory texts on larger screens.

plurals
  1. POCannot get the httpPost params but can get the httpGet from php
    primarykey
    data
    text
    <p>Here is my android code to send request:</p> <pre><code>// defaultHttpClient DefaultHttpClient httpClient = new DefaultHttpClient(); HttpPost httpPost = new HttpPost(serverUrl); List&lt;NameValuePair&gt; params = new ArrayList&lt;NameValuePair&gt;(); params.add(new BasicNameValuePair("abc", "abc2")); httpPost.setEntity(new UrlEncodedFormEntity(params)); HttpResponse httpResponse = httpClient.execute(httpPost); HttpEntity httpEntity = httpResponse.getEntity(); InputStream is = null; is = httpEntity.getContent(); BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8"), 8); StringBuilder sb = new StringBuilder(); String line = null; while ((line = reader.readLine()) != null) { sb.append(line + "\n"); } is.close(); String json = ""; json = sb.toString(); Log.d("JSON", "JSON is:" + json); </code></pre> <p>and here is my php code to get the request:</p> <pre><code>&lt;?php echo $_POST['abc']; ?&gt; </code></pre> <p>When I run the application, the string <code>json</code> is nothing. I expect to get <code>JSON is:abc2</code><br> Then I change the some code, in android part: </p> <pre><code>HttpPost httpPost = new HttpPost(serverUrl); </code></pre> <p>change to: </p> <pre><code>HttpPost httpPost = new HttpPost(serverUrl + "?abc=abc3"); </code></pre> <p>in php part: </p> <pre><code>&lt;?php echo $_GET['abc']; ?&gt; </code></pre> <p>This time, the string <code>json</code> in logcat is <code>JSON is:abc3</code>. It is correct!!<br> I have tried lots of time, but seems cannot send HttpPost request with params.<br> Any one can help me to find out what wrongs with my code??</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload