基本上,我試圖讓我的應用程序執行以下命令執行一個POST請求在Android的
捲曲-i -X POST -d 「用戶= USER &通= PASS」 https://websitehere.com
但我不明白迄今爲止發現的解決方案。如果我使用HttpPost發佈nameValuePairs,這些應該是什麼?
我還在httpclient.execute(httppost)時收到信息ssl-certificate-not-trusted-error的IOException;命令完成。
public void postData(String userString, String passString) {
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("https://websitegoeshere.com");
try {
// Add your data
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("user", userString));
nameValuePairs.add(new BasicNameValuePair("pass", passString));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs, HTTP.UTF_8));
response = httpclient.execute(httppost);
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
你的心不是證書有效。在此處進行測試:https://www.digicert.com/help/index.htm – blindstuff 2012-03-30 19:43:00
您鏈接的網站稱其有效。 – Corith 2012-03-30 22:25:08
某些證書不被android所喜歡,因爲雖然有效,但缺少一些中級證書,請與您的證書提供商聯繫。 – blindstuff 2012-03-30 23:21:29