我应该以
的形式向网站服务发送http帖子POST [messageTitle,messageContent,messageFrom]
它就像名为post
的数组 我在周围搜索,有些人说我应该这样做:nameValuePairs.add(new BasicNameValuePair(“POST []”,messageTitle.getText()。toString())); nameValuePairs.add(new BasicNameValuePair(“POST []”,messageContent.getId())); nameValuePairs.add(new BasicNameValuePair(“POST []”,messageFrom.getText()。toString())); httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
// Execute HTTP Post Request
try {
HttpResponse response = httpclient.execute(httppost);
StatusLine statusLine = response.getStatusLine();
int statusCode = statusLine.getStatusCode();
if (statusCode == 200) {
HttpEntity entity = response.getEntity();
InputStream content = entity.getContent();
BufferedReader reader = new BufferedReader(
new InputStreamReader(content));
String line;
while ((line = reader.readLine()) != null) {
stringBuilder.append(line);
}
} else {
Log.e("JSON", "Failed to download file");
}
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
} catch (IOException e) {
// TODO Auto-generated catch block
}
Log.d("Cat", stringBuilder.toString());
}
但它返回{“result”:0} 并且应该返回{“result”:“row”}