0

Loopj AsynHttpClient

ASP.Net

I am trying to connect to ASP.NET WebApp.
OnSuccess callback, i want to read the webpage and get text and data from the webpage. how can i get it or how can i parse it to the JSON or XML? I successfully Connected to the site by posting params to the login page.Now i want to read redirected webpage. and how can i save cookies or cache so it will automatically login when i run the Android APP.

client.get("https://uogis.uog.edu.pk/LandingPage.aspx", new AsyncHttpResponseHandler(){

                @Override
                public void onFailure(int arg0, Header[] arg1,
                        byte[] arg2, Throwable arg3) {
                    // TODO Auto-generated method stub

                }

                @Override
                public void onSuccess(int arg0, Header[] arg1,
                        byte[] arg2) {
                    // TODO Auto-generated method stub
                    mTextView.setText("In Landing Page now");

                }
                @Override
                public void onFinish() {
                    params.put("TextBox1","Home");
                    client.get("https://uogis.uog.edu.pk/ControlPanel.aspx",new AsyncHttpResponseHandler(){

                        @Override
                        public void onFailure(int arg0,
                                Header[] arg1, byte[] arg2,
                                Throwable arg3) {
                            // TODO Auto-generated method stub

                        }

                        @Override
                        public void onSuccess(int arg0,
                                Header[] arg1, byte[] arg2) {
                            // TODO Auto-generated method stub

                            mTextView.setText("In Control Panel\n"+ "ResponseCode "+arg0+ "\n" );
                        }});

                }
            });
  • Looks to me that the webpage is in arg2 parameter of `onSucces()`. – greenapps Jun 28 '14 at 20:45
  • Yes i think so. But how can i get response.? String s= string(arg2)? – Hashim Lokasher Jul 01 '14 at 11:18
  • What did you try? Maybe `String str = new String(arg2, "UTF-8")` Maybe without the utf-8. And search/google for 'convert byte array to string`. – greenapps Jul 01 '14 at 11:30
  • I tried but it gives me source code of login page, not the login page passed web page/redirected page – Hashim Lokasher Jul 01 '14 at 11:35
  • You have 2 x `onSucces` and an `onFinish` You talk about a redirected webpage. How do you know it is redirected? Where can you determine the url of the redirected page? Are you `getting` the redirected page? Please explain better what is happening and what you are doing. – greenapps Jul 01 '14 at 11:43
  • I want to login on a website using post and then want to browse and get data from different pages of same website – Hashim Lokasher Jul 01 '14 at 11:46
  • That does not answer my question as there is nothing in your answer with `redirected`. – greenapps Jul 01 '14 at 11:51
  • When user login to the website, on authentication user is redirected to another page – Hashim Lokasher Jul 01 '14 at 11:53
  • That I know already. So please answer all my questions about that redirection. I will not repeat them. YOU have to explain. – greenapps Jul 01 '14 at 11:55
  • I don't know anything about the redirected page. That is what is am asking that how can i know that i have reached redirected page – Hashim Lokasher Jul 01 '14 at 11:57
  • You will never `reach` that page if you do not try to `get()` it. For 'getting` a page you need to know its url. Now do you know that url? Are you trying to get it? You have to implement the redirection yourself. Using a browser the browser would do it. – greenapps Jul 01 '14 at 12:02
  • Https://www.uogis.uog.edu.pk/Default.aspx is the login page and redirected page is Https://www.uogis.uog.edu.pk/LandingPage.aspx – Hashim Lokasher Jul 01 '14 at 12:04
  • For both links the server is unreacheble complains my browser. But you are not 'getting' the login page in your code. So how do you want to do a redirection? – greenapps Jul 01 '14 at 12:14
  • That's it what i am asking . guide me whole procedure for login into a site – Hashim Lokasher Jul 01 '14 at 12:15
  • Sorry. I give up as this and earlier answers are not to the point. – greenapps Jul 01 '14 at 12:17
  • Should i use Okhttp, loopj asynchttp or httpurl for connection? – Hashim Lokasher Jul 01 '14 at 12:19

0 Answers0