我需要知道如何POST
使用HTTPS
网络服务。我浏览了教程,但它没有帮助,因为它太旧了。
任何人都可以通过给我一个很好的教程或一些示例代码来帮助我吗?
试试 apache HttpClient库。它支持https。
像这样的东西:
URL url = new URL("https://...");
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
connection.setDoInput(true);
connection.setDoOutput(true);
connection.setRequestMethod("POST");
//write the request body
OutputStream requestBody = connection.getOutputStream();
...
requestBody.flush();
//send the request and get the response body
InputStream responseBody = connection.getInputStream();
...