0
嗨我有很多麻煩提交一個簡單的表單,我已經搜查周圍,它似乎有相當多的人有同樣的問題,但我還沒有找到答案。Android https提交表單?
這裏是我到目前爲止的代碼:
public void postData(TextView txtResult, String user, String pass) throws ClientProtocolException, IOException {
HttpPost post = new HttpPost("https://www.mymeteor.ie");
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("username", user));
nameValuePairs.add(new BasicNameValuePair("userpass", pass));
post.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpClient client = new DefaultHttpClient();
HttpResponse response = client.execute(post);
HttpEntity entity = response.getEntity();
String responseText = EntityUtils.toString(entity);
txtResult.setText(responseText);
}
上面的代碼將簡單地返回原來的頁面,
任何人可以幫助我嗎?
感謝
我不確定我會嘗試那個URL,不幸的是他們不提供任何api謝謝。 –
非常感謝您的工作 –