[問題] 請問 HttpURLConnection::getOutputStr …
玩 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
02/26 11:27, 1F
討論串 (同標題文章)
以下文章回應了本文:
完整討論串 (本文為第 1 之 2 篇):