これは、IAP トランザクションの受信を検証するために使用するコードです。httpsURLConnection.getOutputStream() は SocketException をスローします: 接続のリセット。欠けているものは何ですか?
パブリック クラス HttpsClient {
public static void main(String[] args) {
HttpURLConnection.setFollowRedirects(false);
JSONObject jsonObject = new JSONObject();
jsonObject
.put("receipt-data",
"encodeReceipt");
HttpURLConnection con = null;
try {
String url = "https://buy.itunes.apple.com/verifyReceipt";
con = (HttpURLConnection) new URL(url).openConnection();
HttpsURLConnection httpsURLConnection = (HttpsURLConnection) con;
httpsURLConnection.setDoOutput(true);
OutputStreamWriter wr = null;
wr = new OutputStreamWriter(httpsURLConnection.getOutputStream());
wr.write(jsonObject.toString());
wr.flush();
// Get the response
httpsURLConnection.getInputStream();
BufferedReader rd = new BufferedReader(new InputStreamReader(
httpsURLConnection.getInputStream()));
String line;
while ((line = rd.readLine()) != null) {
System.out.print(line);
}
rd.close();
System.out.println(httpsURLConnection);
} catch (Exception e1) {
e1.printStackTrace();
}
}
}