0
我想用两个参数从一个JSONObject发送POST请求的Python API,它的响应与真或假,但它并没有在所有的工作......的Android DefaultHttpClient()POST请求
我的代码:
// Create a new HttpClient and Post Header
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://10.30.0.47:8080/getsession");
try {
// Add your data
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("Name", db.getString("name")));
nameValuePairs.add(new BasicNameValuePair("Passwort", db.getString("passwort")));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
// Execute HTTP Post Request
HttpResponse res = httpclient.execute(httppost);
Log.v("Response", res.toString());
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
} catch (IOException e) {
// TODO Auto-generated catch block
}
LogCat Output: http://pastebin.com/GL54UFGG
谢谢,这解决了它 –