0

i have a plan to android web parsing after make autologin service... but i have a problem... i try parsing to that http://communion.gntc.net/ i see that www.w3.org/xhtml... xhtml... how to make autologin service... just i know login using 'post method'


Image[Click]

Source try that url connect and try to login but i can't login. just... login read stream source screen again... main.java (some part)

public class Main extends SherlockActivity {
   ........

    public class async_Login extends AsyncTask<String, Void, String> {
        @Override
        protected String doInBackground(String... params) {
            try {
                // URL setting
                communion_Url = new URL("http://communion.gntc.net/Default.aspx");
                connection = (HttpURLConnection) communion_Url .openConnection();

                // <Form> setting
                connection.setRequestProperty("content-type", "application/x-www-form-urlencoded");

                // method choose
                connection.setRequestMethod("POST");

                // transfer mode
                connection.setDoInput(true);
                connection.setDoOutput(true);
                connection.setUseCaches(false);
                connection.setDefaultUseCaches(false);

                // server input info
                StringBuffer buffer = new StringBuffer();
                buffer.append("__VIEWSTATE").append("=").append("%2FwEPDwUKLTIyMDExNjMxNA9kFgICAw9kFgICAw9kFgICBw9kFgICAQ9kFgICCQ8QZGQWAGQYAgUeX19Db250cm9sc1JlcXVpcmVQb3N0QmFja0tleV9fFgEFFExvZ2luVmlldzEkaWJ0bkxvZ2luBRZMb2dpblZpZXcxJG12TG9naW5WaWV3Dw9kZmQyduUiycnsslmd80DsHFWnE%2F5ewQ%3D%3D").append("&");
                buffer.append("__EVENTVALIDATION").append("=").append("%2FwEWBAK%2F9LzRAwK73JjWBAKVqtrbDwLeooalDbXptfMUzAby%2FyAzoqPXkmhJ%2Bq6x").append("&");
                buffer.append("LoginView1%24txtID").append("=").append(params[0]).append("&"); //ID values
                buffer.append("LoginView1%24ibtnLogin.x").append("=").append("1").append("&");
                buffer.append("LoginView1%24ibtnLogin.y").append("=").append("1").append("&");
                buffer.append("LoginView1%24txtPW").append("=").append(params[1]); // PS values
                fileSave(buffer.toString());
                OutputStream opstrm = new     BufferedOutputStream(connection.getOutputStream());
                opstrm.write(buffer.toString().getBytes());
                opstrm.flush(); 
                opstrm.close();

                connection.setRequestMethod("GET");
                InputStream is = connection.getInputStream();
                BufferedReader rd = new BufferedReader(new InputStreamReader(is));
                String line;
                StringBuffer response = new StringBuffer(); 
                while((line = rd.readLine()) != null) {
                    response.append(line);
                    response.append('\r');
                }
                rd.close();

                //fileSave(response.toString());
                Log.i("#async_Login#", response.toString());
            } catch (IOException e) {
                Log.i("##async_Login##", "Communion Connect Failure");
                //e.printStackTrace();
            }

            return null;
        }

        @Override
        protected void onPostExecute(String result) {

        }
    }

.........
}
Nathaniel Jobs
  • 162
  • 1
  • 4
  • 16

1 Answers1

2

You are using GET method: connection.setRequestMethod("GET"); try change it to POST.

koral
  • 2,513
  • 1
  • 32
  • 41