0
我需要在我的應用中做簡單的http post。在Android應用中使用http post
找到示例並創建了AsyncTask
類。做後的主要代碼是這樣的:
nameValuePairs
- 是柱元件
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(URL_STRING);
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs, HTTP.UTF_8));
HttpResponse response = httpclient.execute(httppost);
String data = new BasicResponseHandler().handleResponse(response);
我如何過這種例外
org.apache.http.client.HttpResponseException: Forbidden
這是什麼意思?如果這個服務返回的東西,那麼如何看到完整的消息?
此外,如果有其他的方法,使HTTP POST,我可以試試:)
謝謝你們的幫助。
你添加INTERNET權限到menifest文件? –