我需要在我的应用程序中做简单的 http post。
找到示例并创建AsyncTask
类。post的主要代码是这样的:
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 帖子,我可以试试 :)
谢谢你们的帮助。