2014-02-05 24 views
0

我嘗試將某個應用作爲某個站點的移動版本,這需要授權。 下面是該網站的登錄表單第三方應用中的HttpPost [Android]

<form method="post" 
    action="loginAuth.php" 
    autocomplete="off"> 
    <input id="username" 
     name="username" 
     type="text" 
     class="inp" /> 
    <input id="password" 
     name="password" 
     type="password" 
     class="inp" /> 
    <input type="submit" 
     class="q-button" 
     name="LogIn" 
     value=" Log In"/> 
</form> 

這裏是我的代碼:

public String postData() { 
    HttpClient httpclient = new DefaultHttpClient(); 
    HttpPost httppost = new HttpPost(url + "loginAuth.php"); 
    try { 
     List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2); 
     nameValuePairs.add(new BasicNameValuePair("username", username)); 
     nameValuePairs.add(new BasicNameValuePair("password", password)); 
     httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs, "UTF-8")); 

     HttpResponse response = httpclient.execute(httppost); 
     HttpEntity entity = response.getEntity(); 
     if (entity != null) { 
      String responseBody = EntityUtils.toString(entity); 
      return responseBody; 
     } else { 
      return null; 
     } 

    } catch (ClientProtocolException e) { 
     e.printStackTrace(); 
    } catch (IOException e) { 
     e.printStackTrace(); 
    } 
    return null; 
} 

的問題是,我不能授權和postData()方法再次返回我授權頁面。

+0

,什麼是你的問題? – Budius

+0

Budius,問題是我無法授權並且postData()方法再次返回授權頁面。 我想授權,但我不能 – guny

+0

這一點是:應用程序訪問雲中的東西的正確方式是通過公共API並使用他們自己的應用程序KEY。你試圖實現的是一個詭計多端的解決方法,你可以用hacky的解決方法做很多事情。 – Budius

回答

0

你應該確保這個網站沒有使用SSL,如果你不能沒有他們的證書使SSL請求

+0

謝謝。是否有另一種方法來使請求沒有證書? – guny

+0

好吧聽起來不錯 –