private String httpPostData(String url) { String strResult = null; List params = new ArrayList(); params.add(new BasicNameValuePair("key", "value")); try { HttpPost httpPost = new HttpPost(url); httpPost.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8)); HttpResponse httpResponse = new DefaultHttpClient().execute(httpPost); if (httpResponse.getStatusLine().getStatusCode() == 200) { strResult = EntityUtils.toString(httpResponse.getEntity(), HTTP.UTF_8); } } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } return strResult; }
2014年12月11日 星期四
Android-筆記 HttpPost
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言