-1

我正在尝试使用 post 方法登录网站...到这里代码是代码但响应总是给我 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 回答