-1

postメソッドでWebサイトにログインしようとしています...ここまでコードはコードですが、応答は常に200を返します...正しいユーザー名とパスワードで正常にログインしたかどうかを知りたい!! ! ...また、permitAll()を削除すると、networkonmainthreadexceptionが発生します

@TargetApi(Build.VERSION_CODES.GINGERBREAD)
@SuppressLint("NewApi")
private void sendPost()  {

     // Create a new HttpClient and Post Header
    HttpClient httpclient = new DefaultHttpClient();
    HttpPost httppost = new HttpPost("https://svuonline.org/isis/login.php?");

    String user=username.getText().toString();
    String pass=password.getText().toString();
    String fpage="/isis/index.php";

  /*  if (android.os.Build.VERSION.SDK_INT > 9) {
        StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
        StrictMode.setThreadPolicy(policy);
    }*/

    try {
        // Add your data
        List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
        nameValuePairs.add(new BasicNameValuePair("user_name", user));
        nameValuePairs.add(new BasicNameValuePair("user_pass", pass));
        nameValuePairs.add(new BasicNameValuePair("user_otp", null));
        nameValuePairs.add(new BasicNameValuePair("from_page", fpage));

        httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

        // Execute HTTP Post Request
        HttpResponse response = httpclient.execute(httppost);

        String Rcode=response.toString();

        Toast.makeText(getBaseContext(), Rcode+"", Toast.LENGTH_LONG).show();

    } catch (ClientProtocolException e) {
        Toast.makeText(getBaseContext(), e+"", Toast.LENGTH_LONG).show();
    } catch (IOException e) {
        Toast.makeText(getBaseContext(), e+"", Toast.LENGTH_LONG).show();
    }
}
4

1 に答える 1

0

ここでそれについて読むことができます:

HTTP レスポンス

10.2.1 200 OK

The request has succeeded. 
于 2014-03-31T21:07:45.613 に答える