2011-08-15 28 views
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); 

} 

上面的代碼將簡單地返回原來的頁面,

任何人可以幫助我嗎?

感謝

回答

0

你肯定URL支持通過後這種方式登錄?它看起來像我登錄表單發送到這個網址的發佈數據:https://www.mymeteor.ie/go/mymeteor-login-manager

我也懷疑你應該使用某種API,而不是隻是將數據發佈到他們的登錄表單,遠程。

+0

我不確定我會嘗試那個URL,不幸的是他們不提供任何api謝謝。 –

+0

非常感謝您的工作 –