方法一:使用HttpsURLConnection(响应速度比方法二快)
public static JSONObject verifyReceipt1(String recepit) {
return verifyReceipt1("https://buy.itunes.apple.com/verifyReceipt", recepit);
}
public static JSONObject verifyReceipt1(String url, String receipt) {
try {
HttpsURLConnection connection = (HttpsURLConnection) new URL(url).openConnection();
connection.setRequestMethod("POST");
connection.setDoOutput(true);
connection.setAllowUserInteraction(false);
PrintStream ps = new PrintStream(connection.getOutputStream());
ps.print("{\"receipt-data\": \"" + receipt + "\"}");
ps.close();
BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream()));
St