Ich benutzte eine http-URL, aber jetzt muss ich zu https wechseln. Dies ist mein Code:Wie wird eine HTTPS POST-Anfrage in Android durchgeführt?
throws IOException {
String result = "";
try {
String strPost = "";
for(String key : post.keySet()){
strPost+= key+"="+post.get(key)+"&";
}
strPost = strPost.substring(0,strPost.length()-1);
URL urlPost = new URL(url);
HttpURLConnection urlConnection = (HttpURLConnection)urlPost.openConnection();
urlConnection.setRequestMethod("POST");
urlConnection.setRequestProperty("USER-AGENT", "Mozilla/5.0");
urlConnection.setRequestProperty("ACCEPT-LANGUAGE", "en-US,en;0.5");
urlConnection.setDoOutput(true);
DataOutputStream dStream = new DataOutputStream(urlConnection.getOutputStream());
dStream.writeBytes(strPost);
dStream.flush();
dStream.close();
BufferedReader br = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
String line = "";
StringBuilder responseOutput = new StringBuilder();
while((line = br.readLine()) != null) {
responseOutput.append(line);
}
br.close();
result = responseOutput.toString();
}catch (Exception ex){
}
return result;
}
Ich habe versucht, den Einsatz HttpsURLConnection aber es funktioniert nicht. Ich habe mir andere Fragen dazu angeschaut, aber es hat auch nicht funktioniert.