基本上,我试图让我的应用程序执行以下命令执行一个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