[問題] 請問 HttpURLConnection::getOutputStr …

看板java作者 (bear)時間18年前 (2008/02/25 21:55), 編輯推噓1(100)
留言1則, 1人參與, 最新討論串1/2 (看更多)
玩 android 被迫用 java,實在不太熟... 下面的 code 在 21 行 getOutputStream() 會丟一個 IOException, 說是 Hostname <www.google.com> was not verified 請問這是什麼問題 這明明是 google 的示範 code Q_Q 1 private static final String GOOGLE_AUTH_URL = 2 "https://www.google.com/accounts/ClientLogin"; 3 4 try { 5 // open connection 6 URL url = new URL(GOOGLE_AUTH_URL); 7 HttpURLConnection urlConnection = 8 (HttpURLConnection) url.openConnection(); 9 // set properties of the connection 10 urlConnection.setRequestMethod("POST"); 11 urlConnection.setDoInput(true); 12 urlConnection.setDoOutput(true); 13 urlConnection.setUseCaches(false); 14 urlConnection.setRequestProperty("Content-Type", 15 "application/x-www-form-urlencoded"); 16 // form the POST parameters 17 String content = "accountType=" + ...; 18 19 // post 20 OutputStream outputStream; 21 outputStream = urlConnection.getOutputStream(); 22 outputStream.write(content.toString().getBytes("UTF-8")); 23 outputStream.close(); 24 25 .... 26 } catch(Exception e) {...} -- 信じたのは勇気の心 手にしたのは魔法も力 自分で決めたのことを 負けられない気持ち 逃げたくない気持ち 少しだけと 分かるから だからいま 最初で最後の本気の勝負 自分の魔法のすべてを賭けて  何度でも伝えりよ 笑顔見せて欲しいから   -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 220.135.169.121 ※ 編輯: superbear 來自: 220.135.169.121 (02/25 21:55)

02/26 11:27, , 1F
HTTPS 有加密,需要認證電子簽章
02/26 11:27, 1F
文章代碼(AID): #17miZ0Op (java)
文章代碼(AID): #17miZ0Op (java)