我尝试了几天来获得 HTTPS 连接以连接到 Yobit 公共 API。我不知道我的代码发生了什么。我尝试了很多不同的例子,但在 Yobit 上没有任何效果。我尝试过的那些代码和示例,它们要么给出 411、503 错误,要么给出 MalFormException:no 协议。谁能帮我?我在 Java 上的 HTTPS 或 Web 编程经验非常有限。如果有人可以为我提供解决方案和参考,我将不胜感激。
public void buildHttpsConnection()
{
try {
URL url = new URL("https://yobit.net/api/3/info");
HttpsURLConnection con = (HttpsURLConnection)url.openConnection();
con.setRequestMethod("GET");
con.setRequestProperty("user-Agent", "Mozilla/5.0 (compatible; JAVA AWT)");
con.setRequestProperty("Accept-Language","en-US,en;q=0.5");
con.setDoOutput(true);
con.setUseCaches(false);
System.out.println(con.getResponseCode());
}
catch (Exception e)
{
e.printStackTrace();
}
}